- 2.1之前 https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html
- 3.0 https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html
Simple expressions:
Variable Expressions: ${…}
Selection Variable Expressions: *{…}
Message Expressions: #{…}
Link URL Expressions: @{…}
Fragment Expressions: ~{…}
Literals
Text literals: ‘one text’, ‘Another one!’,…
Number literals: 0, 34, 3.0, 12.3,…
Boolean literals: true, false
Null literal: null
Literal tokens: one, sometext, main,…
Text operations:
String concatenation: +
Literal substitutions: |The name is ${name}|
Arithmetic operations:
Binary operators: +, -, *, /, %
Minus sign (unary operator): -
Boolean operations:
Binary operators: and, or
Boolean negation (unary operator): !, not
Comparisons and equality:
Comparators: >, <, >=, <= (gt, lt, ge, le)
Equality operators: ==, != (eq, ne)
Conditional operators:<mark>三目</mark>
If-then: (if) ? (then)
If-then-else: (if) ? (then) : (else)
Default: (value) ?: (defaultvalue)
Special tokens:
No-Operation: _
循环遍历 each
<tr th:each="emp:${emps}">
<td th:text="${emp.id}" ></td>
<td> [[${emp.lastName}]] </td>
<td th:text="${emp.email}" ></td>
<td th:text="${emp.gender}==0?'女':'男'" ></td>
<td th:text="${emp.department.departmentName}" ></td>
<td th:text="${#dates.format(emp.birth, 'yyyy - MM - dd')}" ></td>
<td>
<a th:href="@{/emp/}+${emp.id}" type="button" class="btn btn-primary">编辑</a>
<button class="btn btn-danger">删除</button>
</td>
</tr>
坑
th:onclick
th:οnclick="function([[${param}]])"
- 《解决th:onclick给js传String类型的值的问题》 - https://blog.csdn.net/qq_38232598/article/details/83187017