In Struts 2, you can set or override the interceptor parameters via the generic <param>
tag. See below example
<package name="default" namespace="/" extends="struts-default">
<action name="whateverAction"
class="com.mkyong.common.action.WhateverAction" >
<interceptor-ref name="workflow">
<param name="excludeMethods">whateverMethod</param>
</interceptor-ref>
<result name="success">pages/whatever.jsp</result>
</action>
</package>
However, in above snippet, the action class is declared it’s own interceptor, and it will cause the immediate lose of the inherit “defaultStack
” interceptors.
What if you want to keep the “defaultStack
” interceptors, and override the workflow’s excludeMethods
parameter as well? No problem, try this
<package name="default" namespace="/" extends="struts-default">
<action name="whateverAction"
class="com.mkyong.common.action.WhateverAction" >
<interceptor-ref name="defaultStack">
<param name="workflow.excludeMethods">whateverMethod</param>
</interceptor-ref>
<result name="success">pages/whatever.jsp</result>
</action>
</package>
The above snippet will keep the “defaultStack
” interceptor and override the “workflow
” parameter.