Interceptor

yaozuodaoforfly 11年前發布 | 4K 次閱讀 5.2.1版本發布

structs.xml 配置

<action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
     <result name="success">/HelloWorld.jsp</result>
     <interceptor-ref name="exception"/>
     <interceptor-ref name="alias"/>
     <interceptor-ref name="params"/>
     <interceptor-ref name="servletConfig"/>
     <interceptor-ref name="prepare"/>
     <interceptor-ref name="i18n"/>
     <interceptor-ref name="chain"/>
     <interceptor-ref name="modelDriven"/>
     <interceptor-ref name="fileUpload"/>
     <interceptor-ref name="staticParams"/>
     <interceptor-ref name="params"/>
     <interceptor-ref name="conversionError"/>
     <interceptor-ref name="validation">
     <param name="excludeMethods">myValidationExcudeMethod</param>
     </interceptor-ref>
     <interceptor-ref name="workflow">
     <param name="excludeMethods">myWorkflowExcludeMethod</param>
     </interceptor-ref>
 </action>
 

Method 2:

 <action name="myAction" class="myActionClass">
   <interceptor-ref name="defaultStack">
     <param name="validation.excludeMethods">myValidationExcludeMethod</param>
     <param name="workflow.excludeMethods">myWorkflowExcludeMethod</param>
   </interceptor-ref>
 </action>

In the first method, the whole default stack is copied and the parameter then changed accordingly.

In the second method, the 'interceptor-ref' refer to an existing interceptor-stack, namely defaultStack in this example, and override the validator and workflow interceptor excludeMethods typically in this case. Note that in the 'param' tag, the name attribute contains a dot (.) the word before the dot(.) specifies the interceptor name whose parameter is to be overridden and the word after the dot (.) specifies the parameter itself

 本文由用戶 yaozuodaoforfly 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!