当前位置: 代码迷 >> JavaScript >> JSP 不能用 不支持 STRUTS标签 报错 The Struts dispatcher cannot be found
  详细解决方案

JSP 不能用 不支持 STRUTS标签 报错 The Struts dispatcher cannot be found

热度:443   发布时间:2013-01-23 10:44:49.0
JSP 不能用 不支持 STRUTS标签 报错 The Struts dispatcher cannot be found.
JSP页加了<%@ taglib prefix="s" uri="/struts-tags"%> 以后,运行显示报错:
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.messageBoard.showMessage_jsp._jspx_meth_s_005fiterator_005f0(showMessage_jsp.java:148)
 at org.apache.jsp.messageBoard.showMessage_jsp._jspService(showMessage_jsp.java:119)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)
 at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
 at java.lang.Thread.run(Thread.java:619)



其实 好办,只要在WEB.XML中加入一个过滤器就行了:

<filter-mapping> 
<filter-name>struts2</filter-name> 
<url-pattern>*.jsp</url-pattern> 
</filter-mapping> 


  相关解决方案