Tim Norman
Tim Norman

Reputation: 431

How to pass parameters while redirecting to another Action using type=redirect?

I need to pass a parameter from an action to the other one, but it runs into following error.

Messages:   
There is no Action mapped for namespace [/Product/Product] and action name [desc] associated with context path [].

struts.xml

 <package name="MyProducts" extends="default" namespace="/Product/Find">
 <result name="Desc" type="redirectAction">
                <param name="actionName">../Product/desc</param>
                <param name="id">${id}</param>
 </result>
 ....

 <package name="Product" extends="default" namespace="/Product">
    ..........

In the first action (in namespace /Product/Find) I am setting the id which has getter and setter.

In the second action (in namespace /Product) I have a id variable and getter and setter.

Upvotes: 2

Views: 1245

Answers (2)

J888
J888

Reputation: 1964

Add another ../ to your address try this ../../Product/desc

or

I know what he means, I thought I just need to answer your question not providing any other approach,

   <result name="YOUR RESULT NAME" type="redirectAction">
           <param name="actionName">desc</param>
           <param name="namespace">/Product</param>
   </result>

Do not forger to precede the namespace name with a / otherwise it does not work. To redirect to an action in default package use / as your namespace param.

Upvotes: 2

Maclane
Maclane

Reputation: 67

The best option will be that you can set the variable in session using session object and then can access that session in the redirected action class..Any way i am looking for your answer by passing variable in the redirect action only...Hoping it was helpful to you.

Upvotes: 0

Related Questions