struts2笔记12-声明式异常

1、配置异常处理

		<action name="save" class="com.test.actions.ProductAction" method="save">
			<exception-mapping result="register" exception="java.lang.ArithmeticException"></exception-mapping>
			<result name="register">/register.jsp</result>
			<result name="save">/detail.jsp</result>
		</action>

2、输出异常

	<s:property value="exception"/>
	<br/><br/>
	<s:property value="exception.message"/>

3、背后的故事

     struts2通过异常拦截器对异常进行了拦截,并放入了值栈中,从而可以通过2的方式进行访问。

原文地址:https://www.cnblogs.com/sdnu/p/5360634.html