手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

springboot中怎么配置错误页面

时间:2024-10-14 09:12:06

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

springboot中怎么配置错误页面

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

springboot中怎么配置错误页面

3、上面的用户体验很不好,痘痉颔湄那么,接下来我们在springboot中配置自定义错误页面:在src/main/resources下建立publi艘早祓胂c/error目录,在下面建两个文件:404.html和5xx.html。

springboot中怎么配置错误页面

4、下面是5xx.html。

springboot中怎么配置错误页面

5、下面是404.html。

springboot中怎么配置错误页面

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

springboot中怎么配置错误页面

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

springboot中怎么配置错误页面

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

© 手抄报圈