日期:2014-05-18  浏览次数:20716 次

struts2的filter问题
<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>/*</url-pattern>
</filter-mapping>


该过滤器这样是过滤所有的请求URL,请问

<servlet>
<servlet-name>UserService</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>UserService</servlet-name>
<url-pattern>/us</url-pattern>
</servlet-mapping>

如果某个URL不想让struts2的filter过滤,要怎么做?谢谢了

------解决方案--------------------
<url-pattern>/*</url-pattern>
这个也只是默认拦截action后缀的请求,真正达到目的自定义一个filter吧
------解决方案--------------------
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>struts2</filter-name>
     <url-pattern>*.jsp</url-pattern>
</filter-mapping> 

这样struts2过滤器就只过滤action
struts2默认是不识别jsp的,因此要将jsp的文件映射到struts2