@的使用
<link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
@要注意加不加“/”的区别
if的使用
<div th:if="${fileUrl eq '${fileUrl}'}">${fileUrl}</div>
<img th:if="${fileUrl eq '${fileUrl}'}" th:src="${fileUrl}" class="img-responsive"/>
1、遍历:
we will use th:each in our template to iterate the list of products:<tr th:each="prod : ${prods}">
<td th:text="${prod.name}">Onions</td>
<td th:text="${prod.price}">2.41</td>
<td th:text="${prod.inStock}? #{true} : #{false}">yes</td>
</tr>
输入:
<input type="text" name="userName" value="James Carrot" th:value="${user.name}" />
value为placeholder,value输入后会被解析覆盖
又如:
<form action="/gtvg/subscribe">
<fieldset>
<input type="text" name="email" />
<input type="submit" value="¡Suscríbeme!"/>
</fieldset>
</form>
1.Text literals: '...'
2.Number literals: 0,1.0,12.3,etc
Simple expression: 表达式语法
1.Message expression : #{}
2.Variable expression : ${}
3.Link URL expression: @{}
4.Selection Variable expression: *{}
结合th:object使用,在某个范围内进行变量的查找,而不是在context中查找,缩小了查询的范围,效率如何呢?
如何没有与th:object结合使用,*{}与${}效果一样,因为其范围自动扩展到context。