Struts2中使用urlrewrite报org.apache.jasper.JasperException: The Struts dispatcher ca

使用Struts2与urlrewrite时

链接地址如下:http://localhost:8080/Finance/index

应该是链接到index.jsp

结果报了错

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:522)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)

javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)

org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)

org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)

org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)

org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)

org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)

org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:61)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)

org.dengzh.filter.EncodeFilter.doFilter(EncodeFilter.java:38)

 

 

仔细检查以后,发现是struts2的filterDispatcher过滤器写成了如下

<filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

把*.action改成*.即过滤所有后缀,就不会出现上述错误,不然会导致struts2的标签无法找到的问题

 

你可能感兴趣的:(java,apache,Web,struts,servlet)