1.boot依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.4.3</version>
</dependency>
1.1名称空间:
xmlns:th="http://www.thymeleaf.org"
2.Thymeleaf语法(Thymeleaf3)
1、th属性,常用th属性如下:
1)th:text:文本替换;
2)th:utext:支持html的文本替换。
3)th:value:属性赋值
4)th:each:遍历循环元素
5)th:if:判断条件,类似的还有th:unless,th:switch,th:case
6)th:insert:代码块引入,类似的还有th:replace,th:include,常用于公共代码块提取的场景
3.表达式语法
${...}
变量表达式,Variable Expressions
@{...}
链接表达式,Link URL Expressions
#{...}
消息表达式,Message Expressions
~{...}
代码块表达式,Fragment Expressions
*{...}
选择变量表达式,Selection Variable Expressions
4.请求传参数
<a th:href="@{/updateUser(id=${user.getId()}"