Struts - 异常 - 无法找到Struts调度程序

Yat*_*oel 1 java jsp struts

我在用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>
Run Code Online (Sandbox Code Playgroud)

但是当我运行上面的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)
Run Code Online (Sandbox Code Playgroud)

Buh*_*ndi 5

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

  • Struts 1适用于Actions
  • Struts 2适用于过滤器和调度程序.

因此,为什么你得到这个:

找不到Struts调度程序.这通常是由于使用没有关联过滤器的Struts标记引起的.Struts标记仅在请求通过其servlet过滤器时可用,该过滤器初始化此标记所需的Struts调度程序. - [未知位置]

获取Struts 1 taglib并替换Struts 2 taglib.

请按照我在这里提出的问题的答案:Struts - Struts中提供的.tld的JSP页面中的Taglib指令

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

  • Roseindia.net:/他们的Java/JSP/JSTL/Servlet/JDBC/JSF教程非常糟糕**.这是一个不好的做法.我不做Struts,所以我不知道他们的Struts教程是否"正确",但整个网站给我一个不好的感觉:http://balusc.blogspot.com/2008/06/what-is-它与 - roseindia.html (2认同)