springboot中怎么配置错误页面

 时间:2026-02-14 10:47:35

1、访问出错后,会展示500错误,如下图:

springboot中怎么配置错误页面

2、访问不存在的页面时,会展示404错误,如下图:

springboot中怎么配置错误页面

3、上面的用户体验很不好,那么,接下来我们在springboot中配置自定义错误页面:

在src/main/resources下建立public/error目录,在下面建两个文件:404.html和5xx.html。

springboot中怎么配置错误页面

4、下面是5xx.html。

springboot中怎么配置错误页面

5、下面是404.html。

springboot中怎么配置错误页面

6、添加完毕后重启系统,再次访问错误页面,展示了我们自定义的5xx页面。

springboot中怎么配置错误页面

7、再次访问不存在的页面,展示了我们自定义的404页面。

springboot中怎么配置错误页面

8、以上就是在springboot中配置404和5xx页面的方法,是不是很简单。

  • 教你用CODESOFT 修改条码对象属性
  • nginx如何配置根据权重转发
  • VB中类的使用
  • Intellij IDEA开发工具中Spring容器的实例化
  • EasyUI中如何弹出Dialog
  • 热门搜索
    2035什么意思 普天同庆的意思 story是什么意思 本命年穿什么 冷静的意思 什么是vcr forest是什么意思 都是浮云是什么意思 游山西村的意思 course是什么意思