springboot中怎么配置错误页面

 时间:2026-04-23 03:27:22

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
  • 热门搜索
    什么是马克思主义中国化 over什么意思 ops是什么意思 hkd是什么意思 什么名字好听又有内涵 舌头发白是什么原因 炜是什么意思 白茶属于什么茶 什么是时尚 不必给我安慰何必怕我伤悲什么歌