通常实现struts的拦截器,需要继承AbstractInterceptor,重写intercept方法。
但是如果需要拦截器中过滤掉某些方法不拦截的话,则需要修改继承的方法了。需要继承MethodFilterInterceptor,重写doIntercept方法。
includeMethods设置需要过滤的方法
<interceptor-ref name="sessionTimeouteInterceptor">
<paramname="includeMethods">method1,method2</param>
</interceptor-ref>
excludeMethods排除需要过滤的方法
<interceptor-ref name="sessionTimeouteInterceptor">
<param name="excludeMethods">method1,method2</param>
</interceptor-ref>
这里面有分全局和局部。
若全局中的param定义为excludeMethods同样局部中的param也定义为excludeMethods,则局部中的param生效,全局中的param无效,即被局部中的param覆盖,同样,若全局中的param定义为includeMethods同样局部中的param也定义为includeMethods,则局部中的param生效,全局中的param无效,即被局部中的param覆盖。
当全局中的param与局部中的param不相同的时,即当全局中param为excludeMethods而局部中的param为includeMethods和全局中的param为includeMethods而局部中param为excludeMethods,则标志为includeMethods生效,即若是全局中的param定义为includeMethods,则全局屏蔽局部,以全局为准,反之,以局部为准。