Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
XML
XML
1struts.xml Global Exception Handling
  
   <global-results>
        <result name="securityerror">/securityerror.jsp</result>
  	<result name="error">/error.jsp</result>
   </global-results>

   <global-exception-mappings>
	<exception-mapping exception="org.apache.struts.register.exceptions.SecurityBreachException" result="securityerror" />
	 <exception-mapping exception="java.lang.Exception" result="error" />
   </global-exception-mappings>
 
  <global-results>
        <result name="securityerror">/securityerror.jsp</result>
  	<result name="error">/error.jsp</result>
   </global-results>
 

The global exception mapping node tells the Struts 2 framework what to do if an uncaught exception of the type specified (or a child of that type) is thrown by the the application. For example if a SecurityBreachException is thrown but not caught, the Struts 2 Action class will return a result of "securityerror". All other uncaught exceptions will cause the Struts 2 Action class to return a result of "error".

...