脱离了和代码的耦合(在action中声明和抛出异常)。
采用拦截器的方式捕获异常。
为了使用Struts2的异常处理机制,必须打开Struts2的异常映射功能,需要一个拦截器.如struts-default.xml中,配置文件开启了异常映射。
<interceptors>
<interceptor name="exception" class="com.opensymphony.xwork.interceptor.ExceptionMapping Interceptor">

</interceptors>
<interceptor-stack name="defaultStack">
    
<interceptor-ref name="exception">
</interceptor-stack>
</interceptors> 

手动抛出异常验证Struts2框架,输出异常信息。
{

}
posted on 2009-11-05 04:03 南朝 阅读(144) 评论(0)  编辑  收藏 所属分类: Struts2

只有注册用户登录后才能发表评论。


网站导航:
 

统计