全局异常映射:
<global-exception-mappings>
</global-exception-mappings>
局部异常映射:
<exception-mappings>
</exception-mappings>
exception: 异常类型
result:指定Action出现该异常时,系统转入result属性所指向的结果。
异常信息的输出:
<s:propertyvalue="exception"/>输出异常对象本身。
<s:propertyvalue="exception.message"/>输出异常对象的信息。
<s:propertyvalue="exceptionStack"/>输出异常对象本身。
1.业务异常类
2.Servlet规范里的异常控制
2.1按error-code统一定义错误页面
<error-page><error-code>404</error-code> <location>/404.jsp</location> </error-page>
<error-page><error-code>500</error-code> <location>/error.jsp</location> </error-page>
2.2按异常类型定义单独错误页面
<error-page><exception-type>org.sprngside.bookstore.UserNotFound</exception-type> <location>/userNotFound.jsp</location> </error-page>
2.3 在JSP里单独定义错误页面
<@ errorPage="error.jsp">
3.Spring MVC里的异常控制
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="defaultErrorView" value="/error.jsp"/> <property name="exceptionMappings"> <props> <prop key="org.springside.framework.base.BusinessException">/businessError.jsp</prop> </props> </property> </bean>
4. error.jsp的处理