@RestControllerAdvice public class ControllerExceptionHandler extends Object
| 构造器和说明 |
|---|
ControllerExceptionHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
bindException(org.springframework.validation.BindException e) |
Object |
exception(org.springframework.web.bind.MethodArgumentNotValidException e) |
Object |
exceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException e) |
Object |
exceptionHandler(org.springframework.web.servlet.NoHandlerFoundException e)
404 拦截必须在配置文件加这个
spring.mvc.throw-exception-if-no-handler-found=true #出现错误时, 直接抛出异常
spring.resources.add-mappings=false #不要为我们工程中的资源文件建立映射
|
Object |
handleBusinessException(BusinessException e)
处理自定义异常
|
Object |
handleException(Exception e) |
Object |
handleHttpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e) |
Object |
handleNullPointerException(NullPointerException e) |
@ExceptionHandler(value=BusinessException.class) public Object handleBusinessException(BusinessException e)
@ExceptionHandler(value=org.springframework.web.servlet.NoHandlerFoundException.class) public Object exceptionHandler(org.springframework.web.servlet.NoHandlerFoundException e)
spring.mvc.throw-exception-if-no-handler-found=true #出现错误时, 直接抛出异常
spring.resources.add-mappings=false #不要为我们工程中的资源文件建立映射
@ExceptionHandler(value=java.lang.NullPointerException.class) public Object handleNullPointerException(NullPointerException e)
@ExceptionHandler(value=org.springframework.web.HttpRequestMethodNotSupportedException.class) public Object handleHttpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e)
@ExceptionHandler public Object exceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException e)
@ExceptionHandler(value=org.springframework.web.bind.MethodArgumentNotValidException.class) public Object exception(org.springframework.web.bind.MethodArgumentNotValidException e)
@ExceptionHandler(value=java.lang.Exception.class) public Object handleException(Exception e)
@ExceptionHandler(value=org.springframework.validation.BindException.class) public Object bindException(org.springframework.validation.BindException e)
Copyright © 2022 tan. All rights reserved.