struts 1.2 /2.0 错误处理

struts 1.2 错误处理:
在 struts-config.xml 中 加入

<global-exceptions >
<exception key="errors.message"    type="java.lang.Exception" path="/errorpage.jsp" scope="request"/>  
</global-exceptions>

其中遇到所有抛出的excrption 类的子类 都会得到捕获并跳转到erroroage.jsp.


struts 2.0 错误处理:

在相应struts配置文件中 加入

<global-results>
     <result name="runtimeException">
/WEBINF/exception/runtimeException.jsp
      </result>
</global-results>
<global-exception-mappings>
         <exception-mapping result="runtimeException"
exception="java.lang.RuntimeException" />
</global-exception-mappings>


这个的功能是可以捕获到所有抛出的runtimeException 并显示runtimeException.jsp

你可能感兴趣的:(xml,jsp,struts)