The struts-default.xml defines a series of interceptor and interceptor chains
A default interceptor defastack stack is also defined. Once the default interceptor is defined,
This interceptor will take effect for all the actions in the package. Of course, if your Action explicitly defines the interceptor,
By default, the interceptor will lose its role. If you want to prevent it from being ineffective,
You must also explicitly define the system's default interceptor.
</interceptors>
<default-interceptor-ref name="defaultStack"/>
<default-class-ref class="com.opensymphony.xwork2.ActionSupport" />
</package>
The "defaultstack" and "paramsprepareparamsstack" Interceptor stacks provide most of the interceptor functions.
The interception sequence is different. The former is usually used, but some problems related to parameter transfer and Value
For example, when the modeldriven interface is implemented, you do not need to write the interceptor class by yourself.
defaultStack
<interceptor-stack name="defaultStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="debugging"/>
<interceptor-ref name="scopedModelDriven"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</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>
paramsPrepareParamsStack
<interceptor-stack name="paramsPrepareParamsStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
</interceptor-ref>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</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>
Defaultstack cannot receive the data required by prepare (), but should use paramsprepareparamsstack interceptor Stack
Before using the prepare interceptor, call the Params Interceptor to receive the form data.
Based on this idea, you can place the Params interceptor before the prepare interceptor by various means.
For example, copy all the interceptors in defaultstack to the custom mystack interceptor stack in struts. xml.
Modify the positions of the two parts in the order of Params and prepare in the paramsprepareparamsstack interceptor stack.