...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<package name="default" extends="struts-default"> <interceptors> <interceptor name="timer" class=".."/> <interceptor name="logger" class=".."/> </interceptors> <action name="login" class="tutorial.Login"> <interceptor-ref name="timer"/> <interceptor-ref name="logger"/> <result name="input">login.jsp</result> <result name="success" type="redirectAction">/secure/home</result> </action> </package> |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<package name="default" extends="struts-default"> <interceptors> <interceptor name="timer" class=".."/> <interceptor name="logger" class=".."/> <interceptor-stack name="myStack"> <interceptor-ref name="timer"/> <interceptor-ref name="logger"/> </interceptor-stack> </interceptors> <action name="login" class="tutuorial.Login"> <interceptor-ref name="myStack"/> <result name="input">login.jsp</result> <result name="success" type="redirectAction">/secure/home</result> </action> </package> |
Looking inside struts-default.xml
, we can see how it's done.
...
Then, only "allowed" will be overridden for the "postPrepareParameterFilter" interceptor in that action, the other params will be null.
Lazy parameters
It is possible to define an interceptor with parameters evaluated during action invocation. In such case the interceptor must be marked with WithLazyParams
interface. This must be developer's decision as interceptor must be aware of having those parameters set during invocation and not when the interceptor is created as it happens in normal way.
Params are evaluated as any other expression starting with from action as a top object.
Code Block | ||||
---|---|---|---|---|
| ||||
<action name="LazyFoo" class="com.opensymphony.xwork2.SimpleAction">
<result name="success">result.jsp</result>
<interceptor-ref name="lazy">
<param name="foo">${bar}</param>
</interceptor-ref>
</action> |
Please be aware that order of interceptors can matter when want to access parameters passed via request as those parameters are set by Parameters Interceptor.
Order of Interceptor Execution
...