2
<action name="AddedPaid"  class="iland.payment.SupplierPaidAction" method="insert">
  <result name="success"  type="redirect">ShowPaid</result>
  <result name="input">/pages/payment/addToPay.jsp</result>
  <result name="login">/pages/login.jsp</result> 
</action>   

<action name="ShowPaid" class="iland.payment.SupplierPaidAction" method="fetchAllByfk">
        <result name="success">/pages/paid/showPaidDetails.jsp</result>
        <result name="input">/pages/payment/ShowPay.jsp</result>
        <result name="login">/pages/login.jsp</result>            
 </action> 

Here AddedPaid Action is used to add form data in to database. After adding data in to database I am redirecting result to ShowPaid action. This is working properly. Now I want whenever I redirect AddedPaid action to ShowPaid. ShowPaid must show data of perticular supplierPaymentId for which I have added data in AddedPaid.

After redirect it is howing url

http://localhost:8082/ClothStore/ShowPaid

I want

http://localhost:8082/ClothStore/ShowPaid?supplierPaymentId=4
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
xrcwrn
  • 5,339
  • 17
  • 68
  • 129

2 Answers2

5

It's strange, usually people have 2 and want 1 :)

Btw, since you are using PostRedirectGet, you need to manually pass the parameter in Struts configuration.

Assuming you have a variable named supplierPaymentId with getter and setter, it's achievable like follows:

<action name="AddedPaid" class="iland.payment.SupplierPaidAction" method="insert">
    <result name="success"  type="redirectAction">
        <param name="actionName">ShowPaid</param>
        <param name="supplierPaymentId">${supplierPaymentId}</param>
    </result>  
    <result name="input">/pages/payment/addToPay.jsp</result>
    <result name="login">/pages/login.jsp</result> 
</action>   

Also use redirectAction instead of redirect, that is meant to be used to redirect to external URLs or non-Action URLs

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • Can we pass `actionErrors' and 'actionMessages' in same way – xrcwrn Jun 12 '14 at 09:29
  • No, because they're Lists, not Strings. You can save them in session in first action and retrieve them in second one, or use the [Scope Interceptor](http://struts.apache.org/release/2.3.x/docs/scope-interceptor.html) that [does that for you automatically](http://stackoverflow.com/a/8442045/1654265). – Andrea Ligios Jun 12 '14 at 09:43
  • 1
    6 years later and solved my own issue perfectly. +1 for aiding my "legacy" support :) – Nick Reed Mar 27 '20 at 21:00
  • Glad that helped @NickReed :) – Andrea Ligios Mar 27 '20 at 22:43
2

First of all use redirectAction result instead of redirect to redirect to another action. And use param tag to add parameters in your result configuration.

<result type="redirectAction">
    <param name="actionName">ShowPaid</param>
    <param name="supplierPaymentId">${supplierPaymentId}</param>
</result>

Note you need to have getter/setter for supplierPaymentId in your action class.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143