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的方式进行访问。

posted @ 2016-04-06 18:59  御灵手  阅读(102)  评论(0编辑  收藏  举报