Struts2 dynamic parameter name when redirecting

I successfully use redirect-action for one of the struts2 mapping files as follows:

<action name="setAsCurrentCart" class="com.fmp.MyAction"> <result name="success" type="redirect-action"> <param name="actionName">myOtherAction</param> <param name="foo">${foo}</param> </result> <interceptor-ref name="defaultComponentStack"/> </action> 

Here is what I want to do:

 <action name="setAsCurrentCart" class="com.fmp.MyAction"> <result name="success" type="redirect-action"> <param name="actionName">myOtherAction</param> <param name="${dynamicParameterName}">${dynamicParameterValue}</param> </result> <interceptor-ref name="defaultComponentStack"/> </action> 

In other words, I want the parameter name I pass in to be dynamic. Does anyone know if this is possible?

+3
source share
2 answers

Actually, this does not work. However, I managed to get this work to do the following:

 <action name="setAsCurrentCart" class="com.fmp.MyAction"> <result name="success" type="redirect-action"> <param name="actionName">myOtherAction</param> <param name="${dynamicParameterName}">${dynamicParameterValue}</param> </result> </action> 

I just assumed this would not work.

+7
source

Could you do it instead?

 <action name="setAsCurrentCart" class="com.fmp.MyAction"> <result name="success" type="redirect-action"> <param name="actionName">myOtherAction</param> <param name="paramName">${dynamicParameterName}</param> <param name="paramValue">${dynamicParameterValue}</param> </result> </action> 
+1
source

Source: https://habr.com/ru/post/1346502/


All Articles