2009年6月22日 星期一

[Struts2]interceptor

Strust2 default interceptor
<default-interceptor-ref name="defaultStack"/>
<interceptor-stack name="defaultStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="debugging"/>
<interceptor-ref name="profiling"/>
<interceptor-ref name="scopedModelDriven"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="staticParams"/>
<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>

如果有多個自定義的interceptor
使用interceptor stack的形式來處理比較方便
<interceptors>
<interceptor-stack name="myStack">
<interceptor-ref name="i18n" />
<interceptor-ref name="params" />
<interceptor-ref name="static-params" />
<interceptor-ref name="LoginInterceptor" /> <!--自定義的-->
</interceptor-stack>
<interceptor name ="LoginInterceptor" class ="myClass" />
</interceptors>

直接引用interceptor stack就不用一個一個加了
<action name="myAction" class="myClass">
<interceptor-ref name="myStack"/>
...
</action>

沒有留言:

張貼留言