struts2 interceptor stack
I write in my struts.xml this interceptor stack
<interceptor-stack name="project-interceptors-stack">
<interceptor-ref name="my1-i" />
<interceptor-ref name="my2-i" />
<interceptor-ref name="paramsPrepareParamsStack" />
<interceptor-ref name="logger" />
<interceptor-ref name="timer" />
</interceptor-stack>
where my1-i and my2-i are my custom interceptor. I do not use this interceptor
<interceptor-ref name="i18n"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="validation">
but, my action's, which are Preparable, ModelDriven and Validateable work well ... why ?
Follow-up: I omitted an importa开发者_高级运维nt detail: the interceptor stack is defined in the first package and is inherited by all sub package.
More precisely i wanted to ask this: why if my action implements Preparable, and i don't have the interceptor '<interceptor-ref name="prepare"/>
' in my custom stack, the prepare method is called correctly?
What do you precisely mean with this?
my actions, which are Preparable, ModelDriven and Validateable work well
You mean that the interceptors appear to be applied, for example, declarative validation is applied? (You can check what each standard interceptor is supposed to do here )
If so, you should check that your stack is effectively used in you action, by specifying it in the action mapping or globally (the code you posted simply defines a stack).
These are included in the paramsPrepareParamsStack. Below is the definition according to struts-default.xml,
<interceptor-stack name="paramsPrepareParamsStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="datetime"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="params"/>
<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"/>
<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>
精彩评论