Search code examples
javajspstruts2action

Java Struts call another action after executed action finished


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>

Solution

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

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