一、静态页面必须放置在 templates 目录下
![](https://img-blog.csdnimg.cn/img_convert/cc6d49204d71e7f8016158208d553eb2.png)
二、类前面的注释为 @Controller,不是 @RestController
@Controller
public class aaa {
@RequestMapping("/test")
public String test(){
return "aaa.html";
}
}
三、添加依赖 spring-boot-starter-thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>