springboot 定制错误页面

项目中经常遇到的异常情况

  • 400-Bad Request
  • 401-Unauthorized

    If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials.

  • 403-Forbidden

    The server understood the request, but is refusing to fulfill it.

  • 404-Resource not found
  • 500-Internal Server Error

定制错误页面的方法

  1. 在src/main/resource/templates/error/目录中增加
  2. 在src/main/resource/public/error/目录中增加

其中第一种方式的优先级大于第二种。
springboot-error-handling

参考文档

posted on 2017-08-25 18:32  James.H.Fu  阅读(515)  评论(0编辑  收藏  举报

导航