微服务 教程
1085个小节阅读:196.4k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
当代码抛出异常后,网页上展示的500错误码比较难看,我们可以对项目进行统一异常处理,跳转到用户体检较好的500页面。
在SpringBoot项目中,当程序出现了异常,SpringBoot会使用自带的BasicErrorController
对象处理异常。该处理器会默认跳转到/resources/templates/error.html
页面,我们只需编写error.html
页面即可进行统一异常处理:
xxxxxxxxxx
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>首页</title>
<th:block th:replace="/backstage/common_resources::common_css"/>
<th:block th:replace="/backstage/common_resources::common_js"/>
</head>
<body class="hold-transition skin-purple sidebar-mini">
<div class="error-page">
<h2 class="headline text-red">500</h2>
<div class="error-content">
<h3><i class="fa fa-warning text-red"></i> Oops! 页面程序有错误.</h3>
</div>
</div>
</body>
</html>