thymeleaf
1> 相关pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
注意:
Spring Boot官方文档建议在开发时将缓存关闭,那就在application.properties文件中加入下面这行
spring.thymeleaf.cache=false
正式环境还是要将缓存开启的
2>修改配置文件application.yml
spring:
thymeleaf:
cache: false
3>代码展示
html页面
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
<meta charset="UTF-8">
<title th:text="${title}"></title>
</head>
<body>
<h2 th:text="${welcome}"></h2>
<h2>数据展示</h2>
<table>
<thead>
<tr>
<th>编号</th>
<th>姓名</th>
<th>性别</th>
</tr>
</thead>
<tbody>
<tr th:each =" user : ${users}">
<th th:text="${user.getUid()}">编号</th>
<th th:text="${user.getUsername()}">姓名</th>
<th th:text="${user.getSex()}"