异常:
严重: Servlet.service() for servlet jsp threw exception
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]
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
at org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:108)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:79)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
解答:
web.xml中struts2过滤器中没有拦截该页面请求,导致jsp页面中的struts2标签无法解析。修改web.xml中struts2过滤器的匹配默认为"/*"即可
本文解决了一个常见的Web开发问题,即在使用Struts2框架时,由于过滤器未正确配置导致无法解析jsp页面中的Struts2标签。通过将web.xml中的过滤器匹配规则更改为/*,可以解决此问题。
538

被折叠的 条评论
为什么被折叠?



