1.错误页面直接定义在templates/error下面就行
<body>
<h2>5xx错误</h2>
<h2>状态码:[[${status}]]</h2>
<h2>错误提示:[[${error}]]</h2>
<h2>异常消息::[[${message}]]</h2>
<h2>时间戳::[[${timestamp}]]</h2>
</body>
2.配置全局异常
//异常通知,处理全局异常
@ControllerAdvice
public class ExceptionAdvice {
//算术异常,其他异常Exception.class
@ExceptionHandler(ArithmeticException.class)
public String arithmetic(Exception e){
System.out.println("出现异常:"+e.getMessage());
return "error/5xx";
}
}