struts2 过滤器

在struts.xml中,关于interceptor相关的节点定义如下:

1.定义interceptor

<interceptors>

<interceptor name="autowiring"
class="…xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
</interceptors>

2.定于interceptor栈

<interceptor-stack name="basicStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="servlet-config"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="params"/>
<interceptor-ref name="conversionError"/>
</interceptor-stack>

3.定义默认interceptor

<default-interceptor-ref name="autowiring"/>

4.在action中使用interceptor

<action name="my" class="com.fdar.infoq.MyAction" >
<result>view.jsp</result>
<interceptor-ref name="basicStack"/>
</action>

原文地址:https://www.cnblogs.com/kevinge/p/1880484.html