The Struts dispatcher cannot be found. 在页面使用struts2的标签时报的异常

来源:互联网 发布:网络存储服务器有哪些 编辑:程序博客网 时间:2024/05/17 22:11

web.xml文件配置:

  <context-param>

  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <filter>
  <filter-name>struts2</filter-name>
  <filter-class>
  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  </filter-class>
  </filter>
  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>*.action</url-pattern>

  </filter-mapping>


在页面中也是正确的引用了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:491)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)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)

在把web.xml里面的 struts2配置映射<url-pattern>*.action</url-pattern>  改为<url-pattern>/*</url-pattern> 就正常了....

这是什么原理?