提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一、依赖
依赖`
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>`
要3.0版本以上的
二、使用步骤
1.引入库
依赖`
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>`
要3.0版本以上的
默认在templates文件夹下.html文件
2.页面
引入
<html lang="en" xmlns:th="http://www.thymeleaf.org"/>
<div th:text="${msg}"></div>
3.后端
@Controller
public class IndexController {
@RequestMapping("/index")
public String index(Model model){
model.addAttribute("msg","hello");
return "index";
}
}
在这里插入图片描述