提交 6abe6c01 authored 作者: aiqingguo's avatar aiqingguo

修改异常返回状态码

上级 fba60c88
...@@ -97,7 +97,7 @@ public class GlobalExceptionHandler { ...@@ -97,7 +97,7 @@ public class GlobalExceptionHandler {
* 统一处理请求参数校验(普通传参) * 统一处理请求参数校验(普通传参)
*/ */
@ExceptionHandler(ConstraintViolationException.class) @ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.OK)
public Result<String> handleConstraintViolationException(ConstraintViolationException e) { public Result<String> handleConstraintViolationException(ConstraintViolationException e) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Set<ConstraintViolation<?>> violations = e.getConstraintViolations(); Set<ConstraintViolation<?>> violations = e.getConstraintViolations();
...@@ -115,7 +115,7 @@ public class GlobalExceptionHandler { ...@@ -115,7 +115,7 @@ public class GlobalExceptionHandler {
* 统一处理请求参数校验(被@RequestBody注解的实体对象传参) * 统一处理请求参数校验(被@RequestBody注解的实体对象传参)
*/ */
@ExceptionHandler(MethodArgumentNotValidException.class) @ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.OK)
public Result<String> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { public Result<String> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<FieldError> fieldErrors = e.getBindingResult().getFieldErrors(); List<FieldError> fieldErrors = e.getBindingResult().getFieldErrors();
...@@ -131,7 +131,7 @@ public class GlobalExceptionHandler { ...@@ -131,7 +131,7 @@ public class GlobalExceptionHandler {
* 统一处理请求参数校验(普通实体对象传参) * 统一处理请求参数校验(普通实体对象传参)
*/ */
@ExceptionHandler(BindException.class) @ExceptionHandler(BindException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.OK)
public Result<String> handleBindException(BindException e) { public Result<String> handleBindException(BindException e) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<FieldError> fieldErrors = e.getBindingResult().getFieldErrors(); List<FieldError> fieldErrors = e.getBindingResult().getFieldErrors();
...@@ -144,7 +144,7 @@ public class GlobalExceptionHandler { ...@@ -144,7 +144,7 @@ public class GlobalExceptionHandler {
} }
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseStatus(HttpStatus.OK)
public Result<String> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) { public Result<String> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e, HttpServletRequest request) {
log.info("请求方式错误-->{}", e.getMessage()); log.info("请求方式错误-->{}", e.getMessage());
// 获取当前请求的方法 // 获取当前请求的方法
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论