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
  • 热门搜索
    飞机场是什么意思 lgbt是什么意思啊 puk码是什么 拍拖什么意思 5.20是什么节日 碱性磷酸酶是什么 未来可期什么意思 钙片什么时候吃 award是什么意思 皮肤黑穿什么颜色显白