@ControllerAdvice public class ControllerExceptionHandler extends Object
| 构造器和说明 |
|---|
ControllerExceptionHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
Response |
bindException(org.springframework.validation.BindException e)
类型转换失败
|
Response |
exception(Throwable e)
方法出错
|
Response |
httpMediaTypeNotAcceptableException(org.springframework.web.HttpMediaTypeNotAcceptableException e)
参数格式错误
|
Response |
httpMediaTypeNotSupportedException(org.springframework.web.HttpMediaTypeNotSupportedException e)
请求格式错误(application/x-www-form-urlencoded、application/json)
|
Response |
httpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e)
方法类型不支持(get、post)
|
Response |
missingServletRequestParameterException(javax.servlet.http.HttpServletRequest request,
org.springframework.web.bind.MissingServletRequestParameterException e)
缺少参数
|
Response |
showMessageException(ShowMessageException e)
传递错误消息
|
Response |
typeMismatchException(javax.servlet.http.HttpServletRequest request,
org.springframework.beans.TypeMismatchException e)
参数类型不匹配
|
@ExceptionHandler(value=java.lang.Throwable.class) @ResponseBody public Response exception(Throwable e)
e - @ExceptionHandler(value=ShowMessageException.class) @ResponseBody public Response showMessageException(ShowMessageException e)
@ExceptionHandler(value=org.springframework.validation.BindException.class) @ResponseBody public Response bindException(org.springframework.validation.BindException e)
@ExceptionHandler(value=org.springframework.web.HttpRequestMethodNotSupportedException.class) @ResponseBody public Response httpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e)
@ExceptionHandler(value=org.springframework.beans.TypeMismatchException.class) @ResponseBody public Response typeMismatchException(javax.servlet.http.HttpServletRequest request, org.springframework.beans.TypeMismatchException e)
e - @ExceptionHandler(value=org.springframework.web.bind.MissingServletRequestParameterException.class) @ResponseBody public Response missingServletRequestParameterException(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.MissingServletRequestParameterException e)
e - @ExceptionHandler(value=org.springframework.web.HttpMediaTypeNotAcceptableException.class) @ResponseBody public Response httpMediaTypeNotAcceptableException(org.springframework.web.HttpMediaTypeNotAcceptableException e)
@ExceptionHandler(value=org.springframework.web.HttpMediaTypeNotSupportedException.class) @ResponseBody public Response httpMediaTypeNotSupportedException(org.springframework.web.HttpMediaTypeNotSupportedException e)
Copyright © 2021. All rights reserved.