springboot 在 BasicErrorController 类里实现了默认的错误处理。只需要将对应的错误提示文件放到 resources/static/error 目录,支持模糊匹配,如:

static/error/4xx.html
static/error/5xx.html
static/error/404.html
static/error/error.html

springboot2 异常处理 404 500 处理 错误页面

运行项目,然后输入不存在的地址,触发 404 错误。

springboot2 异常处理 404 500 处理 错误页面

参考:http://www.fengyunxiao.cn

相关文章:

  • 2022-12-23
  • 2021-08-03
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-01-13
  • 2021-12-12
  • 2021-10-17
  • 2022-01-05
  • 2021-09-19
  • 2021-12-12
相关资源
相似解决方案