| Author |
can one have multiple global-forward
|
jo sim
Ranch Hand
Joined: Apr 24, 2006
Posts: 37
|
|
Hi can I have multiple <global-forward> in struts xml file? <global-forwards> <forward name="home" path="/index.jsp" redirect="true"/> <forward name="us" path="/us.jsp" redirect="true"/> </global-forwards> also how can one use this in action class? for example return mapping.findFoward("forwardname") (IS THIS CORRECT AND WILL IT WORK)
|
 |
Chris Boldon
Ranch Hand
Joined: Aug 10, 2006
Posts: 190
|
|
|
Sounds like you already have all the answers. Looks correct to me.
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
Yes, you can define multiple global forwards. Your code is correct. Forwarding to a global forward is no different than forwarding to a local forward. The only difference is that a global forward can be found from any action, whereas a local forward can be found only from the action for which it is defined. Just make sure that you don't define a global and local forward with the same name.
|
Merrill
Consultant, Sima Solutions
|
 |
jo sim
Ranch Hand
Joined: Apr 24, 2006
Posts: 37
|
|
|
Thank you guys.
|
 |
Brent Sterling
Ranch Hand
Joined: Feb 08, 2006
Posts: 948
|
|
Just make sure that you don't define a global and local forward with the same name.
For the record, this is something that I do often. For example I have a global forward named "failure" that forwards to the default error page. In some cases the action knows how to handle an error so the action definition will provide its own "failure" forward. Based on my experience, the local forward will override the global forward for that action. - Brent
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
Good point, Brent. However, I do remember helping someone through a nasty problem that was caused by him thinking the Action was forwarding to one forward, when it was actually forwarding to another because he had inadvertently defined both a local and global forward with the same name. It's still something to watch out for.
|
 |
 |
|
|
subject: can one have multiple global-forward
|
|
|