This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
My codebase has a lot of lines like this in struts actions: return mapping.findForward("foo");
If I make a typo and it turns out that "foo" is not a valid forward according to the struts config file, when I hit the action in the browser, I get a blank page. Not my designated error page.
Is there some sort of struts-centric way to ensure that an exception is thrown and my error page appears? I just want to know if there is an existing mechanism to do this. I could easily write a method to do it (to be called instead of mapping.findForward()) but it seems that this is something Struts should handle.
the closest struts handles unknown is the action mapping attribute 'unknown' which becomes the action to call when a xxx.do is not found. i don't believe there is such a thing for forwarding. you'll need to write your own. -/a
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
One way is possibly defining your own exception class and throwing it when a mapping.findforward returns a null ActionForward. Then in the action mapping within struts-config you can use the exception tag with your exception type mapped to the specified error jsp page.