在pom中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
在application.properties文件中添加配置,将html页面都放在resources下的templates目录下
# 存放html的目录,此处的classpath为resources
spring.mvc.view.prefix=classpath:/templates/
# 给返回的页面添加后缀名
spring.mvc.view.suffix=.html
controller
public class Test{
//这样返回templates文件下的hello.html页面
@RequestMapping(value = "/hello")
public String test(){
return "hello";
}
将js/css文件都放在static目录下
<script src="../test.js"></script>