版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/maguoliang110/article/details/83513771
springboot 中项目引入依赖 pom文件
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
1. th:text标签用于文本显示;并且用于简单的数学运算;
<td th:text="${username}">magliang</td>
<td th:text="9+7">2018</td>
2 th:utext 用与html中文本替换,常用于富文本编辑后的内容显示到前台页面上
<p th:utext="${article.content}">myname is content</p>
3 th:object 用于i接受实体对象
<tr th:object="${user}">
<td th:text="*{user.name}"></td>
<td th:text="*{user.age}"></td>
<td th:text="*{user!.adress}"></td>
</tr>
4 th:each 用于便利集合中的对象 , 相当于jstl中的<c:foreach>标签
<tr th:each="user,userStat:${messages.list}">
<td th:text="${user.name}"></td>
<td th:text="userStat.index"></td>
</tr>
5 th:src 用于引用外部资源引入, 如图片 js文件
<img th:src="@{../images/image.jpg}"/>
<script th:src="@{../static/jqery.js}"></script>
6 th:select 标签用于选择框选中值 ,通常和th:Each 一起使用
<select name="type" class="form-control" disabled>
<option value="0" th:selected="*{type==0} ? 'selected'">图书</option>
<option value="1" th:selected="*{type==1} ? 'selected'">体育</option>
<option value="3" th:selected="*{type==2} ? 'selected'">游戏</option>
</select>
<select th:remove="all-but-first" name="develop_id" class="form-control" th:field="*{develop_id}">
<option th:each="developer : ${developerList}"
th:value="${developer.id}" th:text="${developer.company_name}">Credit card</option>
</select>