<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中添加了数据的perticular supplierPaymentId的数据。
在重定向之后,它正在运行url。
http://localhost:8082/ClothStore/ShowPaid我想要
http://localhost:8082/ClothStore/ShowPaid?supplierPaymentId=4发布于 2014-06-12 08:49:39
这很奇怪,通常人们有2,想要1 :)
顺便说一句,由于您使用的是PostRedirectGet,所以需要在Struts配置中手动传递参数。
假设您有一个带有getter和setter的名为supplierPaymentId的变量,它可以实现如下所示:
<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代替重定向,这意味着用于重定向到外部URLs或非操作URLs。
发布于 2014-06-12 08:49:31
首先,使用redirectAction结果而不是redirect重定向到另一个操作。并使用param标记在结果配置中添加参数。
<result type="redirectAction">
<param name="actionName">ShowPaid</param>
<param name="supplierPaymentId">${supplierPaymentId}</param>
</result>注意,您需要在操作类中为supplierPaymentId提供getter/setter。
https://stackoverflow.com/questions/24177530
复制相似问题