-
- <package name="struts-default">
- . . .
- <interceptors>
- <interceptor name="execAndWait" class="ExecuteAndWaitInterceptor"/>
- <interceptor name="exception" class="ExceptionMappingInterceptor"/>
- <interceptor name="fileUpload" class="FileUploadInterceptor"/>
- <interceptor name="i18n" class="I18nInterceptor"/>
- <interceptor name="logger" class="LoggingInterceptor"/>
- <interceptor name="modelDriven" class="ModelDrivenInterceptor"/>
- <interceptor name="scoped-modelDriven" class= . . ./>
- <interceptor name="params" class="ParametersInterceptor"/>
- <interceptor name="prepare" class="PrepareInterceptor"/>
- <interceptor name="static-params" class=. . ./>
- <interceptor name="servlet-config" class="ServletConfigInterceptor"/>
- <interceptor name="sessionAutowiring"
- class="SessionContextAutowiringInterceptor"/>
- <interceptor name="timer" class="TimerInterceptor"/>
- <interceptor name="token" class="TokenInterceptor"/>
- <interceptor name="token-session" class= . . . />
- <interceptor name="validation" class= . . . />
- <interceptor name="workflow" class="DefaultWorkflowInterceptor"/>
- . . .
- <interceptor-stack name="defaultStack">
- <interceptor-ref name="exception"/>
- <interceptor-ref name="alias"/>
- <interceptor-ref name="servlet-config"/>
- <interceptor-ref name="prepare"/>
- <interceptor-ref name="i18n"/>
- <interceptor-ref name="chain"/>
- <interceptor-ref name="debugging"/>
- <interceptor-ref name="profiling"/>
- <interceptor-ref name="scoped-modelDriven"/>
- <interceptor-ref name="modelDriven"/>
- <interceptor-ref name="fileUpload"/>
- <interceptor-ref name="checkbox"/>
- <interceptor-ref name="static-params"/>
- <interceptor-ref name="params">
- <param name="excludeParams">dojo/..*</param>
- </interceptor-ref>
- <interceptor-ref name="conversionError"/>
- <interceptor-ref name="validation">
- <param name="excludeMethods">input,back,cancel,browse</param>
- </interceptor-ref>
- <interceptor-ref name="workflow">
- <param name="excludeMethods">input,back,cancel,browse</param>
- </interceptor-ref>
- </interceptor-stack>
- </interceptors>
- <default-interceptor-ref name="defaultStack"/>
- </package>
应用:
如何使用struts2拦截器,或者自定义拦截器。特别注意,在使用拦截器的时候,在Action里面必须最后一定要引用struts2自带的拦截器缺省堆栈defaultStack,如下(这里我是引用了struts2自带的checkbox拦截器):
<interceptor-ref name="checkbox">
<param name="uncheckedValue">0</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"/>
(必须加,否则出错)