[转]openSessionInView 配置备忘

转自网上资料.

配置openSessionInView的时候发现并没有起作用
最后发现原因是:

在web.xml中 osiv的filter在webwork的filter之后。


参考自http://www.iteye.com/topic/20671

这是web.xml里的配置,注意下面的前后顺序
Java代码
<filter-mapping>      
    <filter-name>webwork</filter-name>      
    <url-pattern>/*</url-pattern>      
</filter-mapping>      
<filter-mapping>      
    <filter-name>opensession</filter-name>      
    <url-pattern>*.action</url-pattern>      
</filter-mapping>     
  
<filter-mapping>   
    <filter-name>webwork</filter-name>   
     <url-pattern>/*</url-pattern>   
</filter-mapping>   
<filter-mapping>   
    <filter-name>opensession</filter-name>   
    <url-pattern>*.action</url-pattern>   
</filter-mapping>  

<filter-mapping>   
    <filter-name>webwork</filter-name>   
    <url-pattern>/*</url-pattern>   
</filter-mapping>   
<filter-mapping>   
    <filter-name>opensession</filter-name>   
    <url-pattern>*.action</url-pattern>   
</filter-mapping>  

<filter-mapping>
    <filter-name>webwork</filter-name>
     <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>opensession</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>



上面的<filter-mapping>顺序就会使OpenSessionInView失效.正确的顺序应该是
Java代码
<filter-mapping>      
    <filter-name>opensession</filter-name>      
    <url-pattern>*.action</url-pattern>      
</filter-mapping>      
<filter-mapping>      
    <filter-name>webwork</filter-name>      
    <url-pattern>/*</url-pattern>      
</filter-mapping>     
  
<filter-mapping>   
    <filter-name>opensession</filter-name>   
    <url-pattern>*.action</url-pattern>   
</filter-mapping>   
<filter-mapping>   
    <filter-name>webwork</filter-name>   
    <url-pattern>/*</url-pattern>   
</filter-mapping>  

<filter-mapping>   
    <filter-name>opensession</filter-name>   
    <url-pattern>*.action</url-pattern>   
</filter-mapping>   
<filter-mapping>   
    <filter-name>webwork</filter-name>   
    <url-pattern>/*</url-pattern>   
</filter-mapping>  

<filter-mapping>
    <filter-name>opensession</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>webwork</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


即opensession的<filter-mapping>应该位于webwork的<filter-mapping>前

你可能感兴趣的:(java,xml,Web,Webwork)