异常的配置
- 全局异常映射
<struts>
<package name="default" extends="struts-default">
<global-results> <!-- 全局结果 -->
<result name="exception">/exception.jsp</result>
</global-results>
<global-exception-mappings> <!-- 定义全局异常 -->
<exception-mapping result="exception"
exception="java.io.IOException" />
<exception-mapping result="exception"
exception="java.sql.SQLException" />
</global-exception-mappings>
<action name="ex" class="com.controller.ExAction">
<result name="success">/suc.jsp</result>
</action>
</package>
</struts>
- 局部异常映射
<struts>
<package name="default" extends="struts-default">
<global-results> <!-- 全局结果 -->
<result name="exception">/exception.jsp</result>
</global-results>
<action name="ex" class="com.controller.ExAction">
<result name="success">/suc.jsp</result>
<exception-mapping result="exception" exception="java.io.IOException" /><!--定义action下的异常 -->
</action>
</package>
</struts>
用来定义全局异常
用来定义action下的异常