如何使用参数重定向 [英] How to redirect with parameter

查看:200
本文介绍了如何使用参数重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

此处AddedPaid操作用于将表单数据添加到数据库中. 将数据添加到数据库后,我将结果重定向到ShowPaid操作. 这工作正常. 现在,我想将AddedPaid动作重定向到ShowPaid的任何时候. ShowPaid必须显示我在AddedPaid中添加了数据的垂直supplierPaymentId数据.

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.

重定向后,它是网址

http://localhost:8082/ClothStore/ShowPaid

我想要

http://localhost:8082/ClothStore/ShowPaid?supplierPaymentId=4

推荐答案

很奇怪,通常人们只有2个,想要1:)

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

顺便说一句,由于您正在使用PostRedirectGet,因此需要在Struts配置中手动传递参数.

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

假设您有一个名为supplierPaymentId的具有getter和setter的变量,则可以像下面这样实现:

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>   

也可以使用redirectAction而不是redirect,它用于重定向到外部URL或非Action URL.

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

这篇关于如何使用参数重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆