日期:2014-05-20  浏览次数:20785 次

spring集成struts2报告The Struts dispatcher cannot be found.
在我的spring+struts2集成中,启动服务器时正常,在访问JSP网页的时候就报告如下错误:
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]

似乎是说我在JSP里使用了struts2的标签,但JSP却没有经过struts2的fitlter处理。我的集成方案采用spring的自动装配,
请问我这样的配置错在哪里:

web.xml

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/beans.xml</param-value>
  </context-param>
  
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>




------解决方案--------------------
一定要申明
------解决方案--------------------
在web.xml中struts2的过滤器FilterDispatcher配置了吗,代码要贴全了!
------解决方案--------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<!--Spring ApplicationContext 载入 ,必须-->

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>

</listener>

<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- 配置字符过滤 -->
<filter>
<filter-name>setCharactor</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>


<!-- Spring 刷新Introspector防止内存泄露 -->

<listener>

<listener-class>
org.springframework.web.util.IntrospectorCleanupListener
</listener-class>

</listener>


<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>

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

<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 

 


<!-- FreeMarker view servlet -->
<servlet>