Versions Compared

Key

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

...

In the example applications, the logging is just to the Servlet container's console (see the log4j.xml file for the log settings).

Summary

Struts 2 provides a easy to use configuration for handling uncaught exceptions and redirecting users to appropriate view pages. You can configure exception handling to be global-for all actions-or to just for a specific action. You can also enable the Struts 2 framework to log the uncaught exceptions.

Code Block
XML
XML
1titlestruts.xml Action Specific Exception Mapping

   <action name="actionspecificexception" class="org.apache.struts.register.action.Register" method="throwSecurityException">
     <exception-mapping exception="org.apache.struts.register.exceptions.SecurityBreachException" 
          result="login" />
      <result>/register.jsp</result>
      <result name="login">/login.jsp</result>
   </action>

...

In the example applications, the logging is just to the Servlet container's console (see the log4j.xml file for the log settings).

Summary

Struts 2 provides a easy to use configuration for handling uncaught exceptions and redirecting users to appropriate view pages. You can configure exception handling to be global for all actions or to just for a specific action. You can also enable the Struts 2 framework to log the uncaught exceptions.

...