In the following action class, I\'m using the parameters interceptor.
@Namespace(\"/admin_side\")
@ResultPath(\"/WEB-INF/content\")
@ParentPackage(value = \"
I'm not saying exactly,
sample code following as:
<s:form action="save" method="post">
<s:textfield key="personBean.firstName" />
<s:textfield key="personBean.lastName" />
<s:textfield key="personBean.email" />
<s:textfield key="personBean.phoneNumber" />
<s:select key="personBean.sport" list="sports" />
<s:radio key="personBean.gender" list="genders" />
<s:select key="personBean.residency" list="states" listKey="stateAbbr" listValue="stateName"/>
<s:checkbox key="personBean.over21" />
<s:checkboxlist key="personBean.carModels" list="carModelsAvailable" />
<s:submit key="submit" />
</s:form>
Maybe its not working goto this link:
I've already said in the comment that interceptor parameters are not inherited by the interceptor configs of the parent packages if you define your own set of parameters that override the default settings. See Interceptor Parameter Overriding Inheritance.
There are also some techniques used to obtain two different maps of interceptor parameters, see Getting Interceptor Parameters in Struts2.
The convention plugin creates XWork package configs that inherited from some parent package. See my answer for Struts 2 Convention Plugin Define Multiple Parent Packages.
So, all you have to do is to override the default parameter set by the parent configuration if you want to add your own parameters to the set. Either interceptor
tag or interceptor-stack
tag and you should do it for each interceptor-ref
tag.
The convention plugin uses @InterceprorRef annotation for the same purpose but with a caveat that if applied on the class, it applies on each action of that class. So, be careful when using this annotation on the class level. You are overriding the interceptor stack parameters, so you should use a prefix followed by dot of the interceptor name referenced in the stack for each parameter name, but this only works if you have unique names of the interceptor-ref
s in the stack.
If you have two references of the params
interceptor in the paramsPrepareParamsStack
then you can't override the second params
interceptor-ref
unless you create your own interceptor stack and specify parameter overrides on each reference of the interceptor.
Lets take a look at the 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>
There are 2 params
interceptors. When you are setting excludeParams
parameter in your action class, then this is probably set for the first params
interceptor - parameter for the second interceptor stays default. Now, when the second params
interceptor (with default excludeParams
) is invoked, then given exception is thrown.
You can try to duplicate setting of the excludeParams
parameter to set its also for the second interceptor:
@InterceptorRef(value = "paramsPrepareParamsStack", params = {"params.acceptParamNames", "param1, param2", "params.excludeParams", "extraParam", "params.excludeParams", "extraParam", "validation.validateAnnotatedMethodOnly", "true", "validation.excludeMethods", "load"})})