javastruts2action-mapping

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.


Solution

  • 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.