简体   繁体   中英

Incorrect success forward path in struts 1.2

Incorrect success forward path is set for all the users:

I have this in struts config:

<action path="/abc" type="com.actionclass">
  <forward name="success" path="/jsp/user/abc.jsp" />
</action>

In my action class, I changed the "success" forward path to "www.google.com", if the user satisfies some criteria and then he is getting redirected there.

Although, once any user satisfies this criteria, all the subsequent users are getting redirected to "www.google.com", whether they satisfy the criteria or not, because we are using the same mapping name as "success".

May i know the reason for that? Why the path from struts config is not getting picked as "abc.jsp" for the other users?

PS : If i restart the server, then again it works fine till any user satisfies the criteria and "www.google.com" is set.

Edit: My action is a logout action, and it has the feature the logout users to different urls of their organization, basically once they logout from our app, this class will redirect them to their organization's page, so its a dynamic url coming from database. Although i know its not the correct way but i want to understand the concept here more than the problem's solution.

Changing the "success" forward path programatically changes the struts mapping for the entire app . You should add a new <forward> tag for redirecting users to another mapping.

For example, I think your config would be something like...

<action path="/abc" type="com.actionclass">
   <forward name="success" path="/jsp/user/abc.jsp"/>
   <forward name="redirect" path="www.google.com"/>
</action>

Then you would give a return result of "redirect" in your actionclass to redirect users to google.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM