PSR
PSR

Reputation: 40358

Setting request parameters dynamically in struts.xml in struts2

I have some variables in my action class.

Now I want to redirect to another action by setting those variable values as request parameters. How I can do this?

I'm trying to do it like this:

<result type="redirect">myProfileShow?param1=${value}&param2={value2}</result>

It is not working.

Upvotes: 3

Views: 2747

Answers (1)

zumit
zumit

Reputation: 189

<result type="redirectAction">
    <param name="actionName">myProfileShow</action>
    <param name="param1">${value}</param>
    <param name="param2">${value2}</param>
</result>

where value and value2 should be declared in the Action class. You can also set hard-coded values for value & value2.

    <param name="param1">10</param>   <!--  param1 will be 10 --!>
    <param name="param2">15</param>   <!--  param2 will be 15 --!>

Upvotes: 2

Related Questions