0

I am trying to redirect the action after a POST to the Dologin action to one of two actions. I would the url to reflect the action that i am redirecting to. However, the URL still remains with the action I posted to and not the redirected action. Below is the Struts.xml section -- Thank you

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

    <action name="home">
        <result>/mobile/home.jsp</result>
    </action>

    <action name="Dologin" class="action.LoginAction">
        <result name="success" type="redirectAction">
            <param name="namespace">/mobile</param>
            <param name="actionName">home</param>
        </result>

        <result name="input" type="redirectAction">
            <param name="namespace">/mobile</param>
            <param name="actionName">login</param>
        </result>
    </action>
</package>
Roman C
  • 49,761
  • 33
  • 66
  • 176
Jeffrey
  • 1,068
  • 2
  • 15
  • 25
  • I'm not sure how what you're seeing is possible. (Also, unrelated, but you shouldn't need to specify the namespace if you're redirecting within the namespace.) What version of S2? – Dave Newton Nov 11 '11 at 18:08
  • I'd also recommend putting your JSPs under `/WEB-INF` to disallow direct access. – Dave Newton Nov 11 '11 at 18:11

2 Answers2

0

FWIW, I cannot recreate this behavior.

You may also want to DRY up your package configuration:

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

  <action name="home">
    <result>/mobile/home.jsp</result>
  </action>

  <action name="Dologin" class="action.LoginAction">
    <result name="success" type="redirectAction">home</result>
    <result name="input" type="redirectAction">login</result>
  </action>
</package>
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
0

I have tested what you mentioned here and it do reflect the url on the browser. If you are using ajax request, you would not see the change in the url. You may verify this if you are using html frames also.

It is mentioned in the documentation that this result type redirects the browser url and this does happen. Please refer to the document below:

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

James Jithin
  • 10,183
  • 5
  • 36
  • 51