自定义错误页面有以下三步骤
1.在pom中添加依赖包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.在resources/templates中添加名为error.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>404</title>
</head>
<body>
<h1>页面跑地球上了</h1>
<img src="img_error.jpg" alt="错误页面">
</body>
</html>
3.启动项目,访问不存在的url地址或其他的http错误
4.以上异常处理方式为boot默认处理方式,一旦程序出现了异常boot会往/error的url地址发送请求。在boot中 ,提供了一个叫BasicExceptionController处理/error请求,会跳转到默认显示异常信息页面error.html来展示异常信息。