ITeye博客

struts2异常处理配置

miracle9i · 2008-08-24 21:43 · struts2 · Markdown

可将异常完全抛给struts2框架进行处理。 为实现异常处理,strust2配置了拦截器进行处理:


<interceptors>
	<interceptor name="exception" class="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor"/>
</interceptors>	
<interceptor-stack name="defaultStack">
		<interceptor-ref name="exception"/>
</interceptor-stack>

异常捕捉的处理:

局部异常映射:在<action.../>中 全局异常映射,在<global-exception-mappings.../>中


<exception-mapping result="" exception="package.异常类"></exception-mapping>
属性详解:
	exception:指定该异常映射所设置的异常类型
	result:指定Action出现异常时,系统转入此属性所指向的结果
		全局映射指向global-result下的result
		局部映射指向本Action下的result

页面输出异常信息:

<s:property value="exception"/>输出异常对象本身
<s:property value="exceptionStack"/>输出异常堆栈信息

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。