我有一个GlobalExceptionhandler:
@ControllerAdvice
public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(FooException.class)
public ModelAndView alreadyVerifiedExceptionHandler(FooException ex) {
ModelAndView response = new ModelAndView();
response.addObject("status", ex.getStatus());
response.addObject("errorCode", ex.getErrorCode());
response.addObject("errorMessage", ex.getErrorMessage());
return response;
}
.....
}
我有几个ExceptionHandler,默认情况下我会有一个ExceptionHandler。怎么办?
春季版:3.2.3
答案 0 :(得分:0)
这样可行,但它会捕获所有没有ExceptionHandler的异常。
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = {Exception.class, RuntimeException.class})
public ModelAndView defaultErrorHandler(Exception ex) {
...
}