This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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.