2014-12-19 70 views
0

我使用Struts2的。Struts 2的操作重定向

localhost:8084/Web/viewProductsAction?idProducts=1 

後,我看到這個產品,我發表評論

而且它的成功,但我得到搬到localhost:8084/Web/listProductsAction

這裏是struts.xml

<action name="listProductsAction" class="com.struts2.action.ProductsAction" method="viewProducts"> 
    <result name="success">/products.jsp</result>    
</action> 
<action name="sendComments" class="com.struts2.action.CommentsAction" method="sendComments"> 
    <result name="success" type="redirect">listProductsAction</result> 
</action> 

代碼,但我想以後發表評論,轉發給localhost:8084/Web/viewProductsAction?idProducts=1

我該怎麼做?

+0

什麼是上述網址的動作配置? – 2014-12-19 12:15:48

+0

U是指web.xml文件? – king37sniper 2014-12-19 12:31:20

+0

您已經發布了唯一的操作配置以XML爲兩個動作'listProductsAction'和'sendComments'。什麼是'localhost上的操作配置:?8084 /網絡/ viewProductsAction idProducts = 1'? – 2014-12-19 12:35:59

回答

0

更改redirect結果redirectAction結果的位置和地點viewProductsAction。發佈後,它會轉到上一頁。

<action name="sendComments" class="com.struts2.action.CommentsAction" method="sendComments"> 
    <result name="success" type="redirectAction">viewProductsAction?idProducts=1</result> 
</action> 
+0

它返回此網址'http:// localhost:8084/Web/viewProductsAction.action' – king37sniper 2014-12-19 12:47:47

+0

嘗試使用參數 – 2014-12-19 12:49:11

+0

我堅持在這一點上,我如何使用struts參數.xml文件 – king37sniper 2014-12-19 12:55:01