@ControllerAdvice @RestControllerAdvice public class BaseAdvice extends Controller
异常信息拦截处理
| Constructor and Description |
|---|
BaseAdvice() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttributes(org.springframework.ui.Model model)
把值绑定到Model中,
使全局@RequestMapping可以获取到该值
|
String |
businessException(BusinessException e)
拦截业务异常
事务回滚处理
|
String |
commonException(CommonException e)
通用异常信息
|
String |
crontabException(CrontabException e)
定时任务失败
|
String |
defaultException(Exception e)
全局异常拦截
处理全局异常
|
String |
httpMediaTypeNotSupportedException(org.springframework.web.HttpMediaTypeNotSupportedException e)
媒体类型拦截
|
String |
httpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e)
请求方式拦截
|
void |
initBinder(org.springframework.web.bind.WebDataBinder binder)
应用到所有@RequestMapping注解方法,在其执行之前初始化数据绑定器
|
String |
instrumentException(InstrumentException e)
工具异常拦截
|
String |
noHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException e)
资源未找到
|
String |
ValidateException(ValidateException e)
参数验证失败
|
@InitBinder public void initBinder(org.springframework.web.bind.WebDataBinder binder)
binder - 绑定器@ModelAttribute public void addAttributes(org.springframework.ui.Model model)
model - 对象@ResponseBody @ExceptionHandler(value=java.lang.Exception.class) public String defaultException(Exception e)
e - 异常信息@ResponseBody @ExceptionHandler(value=CommonException.class) public String commonException(CommonException e)
e - 异常信息@ResponseBody @ExceptionHandler(value=InstrumentException.class) public String instrumentException(InstrumentException e)
e - 异常信息@ResponseBody @ExceptionHandler(value=BusinessException.class) public String businessException(BusinessException e)
e - 异常信息@ResponseBody @ExceptionHandler(value=CrontabException.class) public String crontabException(CrontabException e)
e - 异常信息@ResponseBody @ExceptionHandler(value=ValidateException.class) public String ValidateException(ValidateException e)
e - 异常信息@ResponseBody @ExceptionHandler(value=org.springframework.web.HttpRequestMethodNotSupportedException.class) public String httpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e)
e - 异常信息@ResponseBody @ExceptionHandler(value=org.springframework.web.HttpMediaTypeNotSupportedException.class) public String httpMediaTypeNotSupportedException(org.springframework.web.HttpMediaTypeNotSupportedException e)
e - 异常信息@ResponseBody @ResponseStatus(value=NOT_FOUND) @ExceptionHandler(value=org.springframework.web.servlet.NoHandlerFoundException.class) public String noHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException e)
e - 异常信息Copyright © 2019. All rights reserved.