【问题标题】:Struts - Exception - The Struts dispatcher cannot be foundStruts - 异常 - 找不到 Struts 调度程序
【发布时间】:2011-01-24 14:52:44
【问题描述】:

我正在使用Struts 2.1.8.1。我想使用由struts 提供的标签,我的jsp 页面。例如

<%@ taglib prefix="html" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Transfer Program - Login</title>
   </head>
   <body>
       <html:form action="/loginaction.do" method="post">
           Username:<html:text name="username"></html:text>
       </html:form>
   </body>
</html>

但是当我运行上面的jsp页面时,出现如下错误:

The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)

【问题讨论】:

    标签: java jsp struts


    【解决方案1】:

    不能在 Struts 1 中使用 Struts 2 标签。Struts 2 来自 WebWorks 项目,它不向后兼容 Struts 1。

    • Struts 1 与 Actions 配合使用
    • Struts 2 与过滤器和调度程序一起使用。

    因此你得到这个:

    找不到 Struts 调度程序。 这通常是由使用 Struts 引起的 没有关联过滤器的标签。 Struts 标签仅在以下情况下可用 请求已通过其 servlet 过滤器,它初始化 Struts 此标签所需的调度程序。 - [未知位置]

    获取 Struts 1 标签库并替换 Struts 2 标签库。

    在此处关注我对您问题的回答:Struts - Taglib directive in a JSP page for .tld provided by Struts

    编辑一个很好的教程网站:

    【讨论】:

    • 没错。也许你可以向他推荐一个清晰简洁的 Struts 教程/指南。判断他的问题历史告诉我,他很难正确处理 Struts 问题:)
    • @Balcus @Elite 实际上我最近从Sun Microsystems 提供的书籍中学习了Struts,并尝试在我的一个项目中使用它。书中没有提到struts的版本,这就是为什么我下载了最新版本的struts来使用......但现在我认为正如书中提到的Action,它是关于struts 1.. .(如果我错了,请纠正我)...
    • 天啊...Struts 有数以百万计的教程(因为它可能刚开始)。我会尝试找到对他有帮助的东西,但一个好的开始是访问 Struts 主页本身 (struts.apache.org)
    • @Yatendra,Sun 很好,但 Struts 不是 Sun。是的,Actions 适用于 Struts 1。看看我编辑的帖子,有很多很棒的网站发布了关于 Struts 的教程。
    • Roseindia.net :/ 他们的 Java/JSP/JSTL/Servlet/JDBC/JSF 教程是可怕的。这是一种不好的做法。我不做 Struts,所以我无法判断他们的 Struts 教程是否“正确”,但整个网站给我一种不好的感觉:balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html
    猜你喜欢
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多