【SpringBoot学习】10-错误处理

当在页面访问时出现类似404、500之类的错误,直接给用户返回报错页面是及其不友好的

如果集成了thymeleaf则可以在template下直接在error文件夹,创建对应错误代码的html页面

该页面也可以通过th语句获取错误信息
在这里插入图片描述
如果在static和templates中都创建了error文件夹,并对应了错误代码

则会优先选择准确的代码html

否则会选择templates中的

<body>
        4xx错误
<p>[[${timestamp}]]</p>
<p>[[${status}]]</p>
<p>[[${message}]]</p>
<p>[[${exception}]]</p>
<p>[[${error}]]</p>
<p>[[${company}]]</p>

</body>
发布了44 篇原创文章 · 获赞 7 · 访问量 840

猜你喜欢

转载自blog.csdn.net/ange2000561/article/details/104719206