SpringBoot中自定义错误页面

错误页面定制(在有模板引擎的情况下):

有模板的支持下: 在templates文件夹下 建立 error文件夹
error文件夹下
404.html
500.html

4xx.html (名字就叫4xx.html)
5xx.html 

就像这样:

错误消息的定制:

  timestamp:时间戳

​    status:状态码

​    error:错误提示

​    exception:异常对象

​    message:异常消息

​   errors:JSR303数据校验的错误都在这里

  通过[[${status}]]获取这样获取!

 比如这样:



SpringBoot如果出现上面的问题 会自动转到该页面!!

测试效果:

猜你喜欢

转载自www.cnblogs.com/gu-bin/p/11134593.html