struts2报错The Struts dispatcher cannot be found

来源:互联网 发布:北京淘宝代运营w863 编辑:程序博客网 时间:2024/06/18 07:17
转载自:今天学习struts2的验证,突然出现了下面这个异常郁闷死了
org.apache.jasper.JasperException: 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.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

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)org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)org.apache.jsp.validation.signup_jsp._jspx_meth_s_005ffielderror_005f0(signup_jsp.java:109)org.apache.jsp.validation.signup_jsp._jspService(signup_jsp.java:76)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)javax.servlet.http.HttpServlet.service(HttpServlet.java:728)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.37 logs.


  #原来是要将web.xml文件的filter配置改成下面这样:
    <filter>
        <filter-name>StrutsPrepareAndExecuteFilter</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>StrutsPrepareAndExecuteFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


  #也有可能是没有导进标签库,导入标签:

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

阅读全文
0 0
原创粉丝点击