He Su
He Su

Reputation: 15

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>

Upvotes: 1

Views: 9858

Answers (2)

Pravin
Pravin

Reputation: 1147

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

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

Upvotes: 2

jjlema
jjlema

Reputation: 850

You can redirect using something like:

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

Upvotes: 2

Related Questions