我正在使用Struts2。
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 :(得分:0)
将redirect
结果的位置更改为redirectAction
结果和位置viewProductsAction
。发布后,它将转发到上一页。
<action name="sendComments" class="com.struts2.action.CommentsAction" method="sendComments">
<result name="success" type="redirectAction">viewProductsAction?idProducts=1</result>
</action>