How to redirect with parameter

一曲冷凌霜 提交于 2019-12-07 07:14:26

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!