Redirect to default action in Struts 2

Posted by topher-j on Stack Overflow See other posts from Stack Overflow or by topher-j
Published on 2010-02-08T12:05:54Z Indexed on 2010/03/15 2:49 UTC
Read the original article Hit count: 338

Filed under:
|

I have an action with an empty string for name defined in the root namespace, and I want to redirect to that action from another action if a certain result is found, but it doesn't seem to work.

Here's the default action

<action name="" class="com.example.actions.HomeAction">
    <result name="success" type="freemarker">freemarker/home.ftl</result>
</action>

And I'm defining the redirect in the global-results for the package:

<global-results>
    <result name="sendToRouting" type="redirectAction">
        <param name="actionName"></param>
        <param name="namespace">/</param>
    </result>
</global-results>

I've tried taking out the actionName parameter, but that doesn't work. If I put a name in for the HomeAction and reference it by name in the global-results it works, so I'm assuming the problem is lack of action name for the redirect.

Any thoughts?

© Stack Overflow or respective owner

Related posts about struts2

Related posts about redirect