marknorkin
marknorkin

Reputation: 4064

How to refer to another package action in struts.xml?

I'm using Struts 2 framework and I've been playing around with such referencing, but cannot find the proper one. For example I have following packages struts.xml file:

<package name="home" namespace="/" extends="struts-default">
    <action name="index">
        <result>/index.jsp</result>
    </action>
</package>

<package name="client" namespace="/client" extends="struts-default">
    <action name="register"
        class="magazine.action.client.RegisterClientAction"
        method="execute">
        <result name="success" type="redirectAction">/index</result>
        <result name="input" type="redirectAction">register_display</result>
    </action>
</package>

Is there a way to refer from success register action in client package to index.jsp page from home package ?

Upvotes: 0

Views: 1428

Answers (1)

Dave Newton
Dave Newton

Reputation: 160181

Use the namespace attribute in the <result>, e.g.,

<result name="success" type="redirectAction">
  <param name="actionName">index</param>
  <param name="namespace">/</param>
</result>

As per the S2 docs:

https://struts.apache.org/docs/redirect-action-result.html

Upvotes: 1

Related Questions