Java Struts call another action after executed action finished

不羁的心 提交于 2019-12-25 07:03:36

问题


I'm using Java and Struts2. In my struts.xml configure file i have blow config.

<action name="copyTestSuite" class="testSuiteAction"
    method="copyTestSuite">
    <result name="success">/WEB-INF/jsp/FormSuccessfulWithOutCloseWindow.jsp
    </result>
</action>

After i executed action copyTestSuite, the default page will go to FormSuccessfulWithOutCloseWindow.jsp. and this page is just used to redirect to previous page.

But i want to let it go to another action matched page directly. How can i do this?

Below is another action toUpdateTestSuite i want to redirect to:

<action name="toUpdateTestSuite" class="testSuiteAction"
    method="toUpdateTestSuite">
    <result name="success">/WEB-INF/jsp/testsuite/updateTestSuite.jsp
    </result>
</action>

回答1:


You can use this <result type="redirectAction"></result>

<action name="copyTestSuite" class="testSuiteAction"
method="copyTestSuite">
<result type="redirectAction">/newAction.action</result>
</action>



回答2:


You can redirect using something like:

<action name="copyTestSuite" class="testSuiteAction" method="copyTestSuite">
    <result type="redirectAction">
        <param name="actionName">toUpdateTestSuite</param>        
    </result>
</action>


来源:https://stackoverflow.com/questions/26998091/java-struts-call-another-action-after-executed-action-finished

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