Spring:SimpleMappingExceptionResolver异常处理
来源:互联网 发布:网络直播土豪是假的 编辑:程序博客网 时间:2024/05/22 00:19
1. 在applicationContext.xml中配置exceptionResolver
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView">
<value>error</value>
</property>
<property name="exceptionMappings">
<props>
<prop key="java.sql.SQLException">errorDB</prop>
<prop key="java.lang.RuntimeException">errorRT</prop>
</props>
</property>
</bean>
2. errorRT.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.lang.Exception" %>
<%@ page import="java.io.PrintWriter" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%Exception ex=(Exception)request.getAttribute("exception");%>
<H2>Exception:</H2>
<%ex.printStackTrace(new PrintWriter(out));%>
<!--<c:out value="${exception}"></c:out>-->
</body>
</html>
- Spring:SimpleMappingExceptionResolver异常处理
- Spring:SimpleMappingExceptionResolver异常处理
- Spring:SimpleMappingExceptionResolver异常处理
- Spring MVC异常处理SimpleMappingExceptionResolver【转】
- Spring MVC 全局异常处理(1) --SimpleMappingExceptionResolver
- Spring MVC 全局异常处理(1) --SimpleMappingExceptionResolver
- SpringMvc声明式异常处理之SimpleMappingExceptionResolver
- 自定义SimpleMappingExceptionResolver实现个性化的异常处理
- 13.4、异常处理——SimpleMappingExceptionResolver
- Spring异常处理
- Spring MVC异常处理
- Spring异常处理
- spring 异常本地处理
- spring 异常处理
- Spring Aop异常处理
- spring mvc处理异常
- Spring + jpa 异常处理
- Spring统一异常处理
- 关于 鱼宝宝的一些代码
- 心情周记
- Python的repr和str有什么不同?
- libcurl在vc6下的安装(这个狂赞的,按照以下步骤使用libcurl绝对没有问题)
- InvokeHelper
- Spring:SimpleMappingExceptionResolver异常处理
- 并发测试瓶颈
- 架构师之我见
- netbean 更新至6.8版本
- domain和link的区别详解
- 使用 python 写 COM
- IT生活
- 相册密码工具
- 如何保持屏幕高亮