@ExceptionHandler
来源:互联网 发布:个人网络贷款 编辑:程序博客网 时间:2024/06/01 08:55
1、@ExceptionHandler
spring MVC 中的@ExceptionHandler可以对web的服务器端运行错误, 做统一的处理,使得http status code 从原本的500改成200,(状态码500--服务器遇到未知错误,导致无法完成客户端当前请求,200--服务器已成功接收并将处理结果返回给客户端)并去执行用@ExceptionHandler注解的方法。 前提是实现了这个方法的Class被那个访问的Controller 继承了。
//错误@RequestMapping("/admin")@ResponseBodypublic String admin(@RequestParam(value="key",required=false) String key){if("admin".equals(key)){return "hello admin";}else{throw new IllegalArgumentException("key 错误");}}//处理错误@ExceptionHandler@ResponseBodypublic String error(Exception e){return "error:"+e.getMessage();}
2/
阅读全文
0 0
- @ExceptionHandler
- @ExceptionHandler
- Android ExceptionHandler
- Android ExceptionHandler
- RESTFUL ExceptionHandler
- 统一异常处理@ExceptionHandler
- 统一异常处理@ExceptionHandler
- springboot 全局异常-ExceptionHandler
- Spring MVC @ExceptionHandler的使用
- controller错误统一处理--------@ExceptionHandler
- Spring MVC @ExceptionHandler 的使用
- struts中利用ExceptionHandler处理异常
- 用@ExceptionHandler 来进行异常处理
- spring基于@ExceptionHandler的异常处理
- Spring 注解学习@ExceptionHandler 和@ResponseStatus
- 用@ExceptionHandler 来进行异常处理
- 使用ExceptionHandler进行Spring mvc 异常处理
- @ControllerAdvice + @ExceptionHandler 全局处理 Controller 层异常
- jquery如何判断滚动条滚到页面底部并执行事件
- Mybatis中动态SQL语句中的parameterType不同数据类型的用法
- Xcode 的清理
- jQuery判断checkbox是否选中
- 4.4抽象类
- @ExceptionHandler
- django.core.exceptions.ImproperlyConfigured:
- Android开发艺术探索学习摘要(五)
- c# 面向对象基础技能
- [Leetcode] 152. Maximum Product Subarray
- git使用手册
- 在C程序中调用汇编函数
- Scala学习七:数组
- [Debug]