SimpleMappingExceptionResolver的使用
来源:互联网 发布:from unixtime mysql 编辑:程序博客网 时间:2024/06/16 13:51
//处理器方法如下
@RequestMapping("/testSimpleMappingExceptionResolver")
public String testSimpleMappingExceptionResolver(){
String[] values=new String[10];
System.out.println(values[10]); //会报ArrayIndexOutOfBoundsException
return "success";
}
SpringMVC的配置文件增加如下内容:
<!-- 配置SimpleMappingExceptionResolver -->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<!-- 在error.jsp中可以使用EL表达式${exception}获取发生的异常值,默认的值就是exception -->
<property name="exceptionAttribute" value="exception"></property>
<property name="exceptionMappings">
<props>
<!-- 出现java.lang.ArrayIndexOutOfBoundsException异常时,转向逻辑视图error -->
<prop key="java.lang.ArrayIndexOutOfBoundsException">error</prop>
</props>
</property>
</bean>
这样,访问接口/testSimpleMappingExceptionResolver时,就会转向error.jsp页面。并且在error.jsp页面通过${exception}可以获取刚才发生的异常:java.lang.ArrayIndexOutOfBoundsException: 10
- SimpleMappingExceptionResolver的使用
- SimpleMappingExceptionResolver的使用
- SimpleMappingExceptionResolver的使用
- SimpleMappingExceptionResolver的使用方法
- 自定义SimpleMappingExceptionResolver实现个性化的异常处理
- Spring:SimpleMappingExceptionResolver异常处理
- Spring:SimpleMappingExceptionResolver异常处理
- Spring:SimpleMappingExceptionResolver异常处理
- SpringMvc声明式异常处理之SimpleMappingExceptionResolver
- Spring MVC异常处理SimpleMappingExceptionResolver【转】
- 13.4、异常处理——SimpleMappingExceptionResolver
- springmvc学习笔记(30)——SimpleMappingExceptionResolver异常映射
- Spring MVC 全局异常处理(1) --SimpleMappingExceptionResolver
- Spring MVC 全局异常处理(1) --SimpleMappingExceptionResolver
- GUID使用的使用
- ${}的使用
- 的使用
- @[],@()的使用
- mysql 中位数
- C++走向远洋——62(项目二1、类模板)
- 最大公约数最简单的写法(北航13年机试)
- 分析v7中的LinearLayoutCompat类
- 第三方插件
- SimpleMappingExceptionResolver的使用
- create file遇到操作系统错误5拒绝访问
- 实用软件推荐(1)
- Google 分析 SDK 之渠道统计
- 树莓派安装系统和制作镜像
- 66. Plus One [easy] (Python)
- 调试入门
- 数组——矩阵清零
- Django学习笔记--文章显示的处理