- Global Exception Handling
<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>
- Exception Handling Per Action
<action name="user!*" class="earthworm.UserAction" method="{1}">
<exception-mapping exception="java.io.IOException" result="exceptionpage"/>
<result type="dispatcher">/addUser.jsp</result>
<result name="back">/index.jsp</result>
<result name="exceptionpage">/userexception.jsp</result>
</action>
<package name="default" namespace="/" extends="struts-default">
<interceptors>
<interceptor-stack name="appDefaultStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="appDefaultStack" />
.....
</package>
- Display Exception Information In Browser
<p>this is page for user action</p>
<h4>Exception Name: <s:property value="exception" /> </h4>
<h4>Exception Details: <s:property value="exceptionStack" /></h4>