经常在使用struts的标签的时候会包这种异常:
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.JasperException: An exception occurred processing JSP page /login.jsp at line 68
65: </td>
66: </tr>
67: </table>
68: <font color="red" size="3"><s:property value="result"/></font>
69: <br/>
70: </form>
71:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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.login_jsp._jspx_meth_s_005fproperty_005f0(login_jsp.java:169)
org.apache.jsp.login_jsp._jspService(login_jsp.java:129)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
其实就是那个标签那里报错了。
那解决办法也很简单:只要将标签<s:property value="result"/>换成最简单的jsp标签就行了${result }
但是如果是一个list,就没有办法,归根结底还是struts的问题。参考点击打开链接
解决的办法:(4种解决方案)
1.
web.xml 中添加一个filter
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/action/*</url-pattern>
</filter-mapping>
2.
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>