1.變量表達式 ${……}javascript
<input type="text" name="userName" value="niu" th:value="${name}" />
2.URL表達式 @{……} (括號內爲參數,以「,」分割)java
<a href="javascript:void(0)" th:href="@{/customer/detail/choseWearingPart(kind='剎車片',catId='4119,4103,4133,4093,4131')}"
3.簡單數據轉換(數字,日期)數組
<dt>價格</dt> <dd th:text="${#numbers.formatDecimal(product.price, 1, 2)}">180</dd> <dt>進貨日期</dt> <dd th:text="${#dates.format(product.availableFrom, 'yyyy-MM-dd')}">2014-12-01</dd>
4.字符串拼接session
<dd th:text="${'$'+product.price}">235</dd>
5.數組 (遍歷數據展現)spa
<th:block th:each="customer:${customer}"> <span th:text="${customer.contactsName}">楊老闆</span> <span th:text="${customer.contactsMobile}">13525737813</span> <span class="currentArea" th:text="${customer.address}">杭州-西湖區</span> </th:block>
6.條件判斷(不能用"<」,">","="等符號,要用"lt,gt,eq"替代)code
<span th:if="${product.price lt 100}" class="offer">Special offer!</span>
多個if條件用and鏈接:orm
th:if="${standDetailStat.size} ==1 and ${standDetail.purchaseInfoAttachId} == -1"
7.map (用key獲取value)索引
<div th:each="standDetail:${customerClassifyInfoVO.standardPartsMap.get('油品')}」></div>
map的value是一個list,所以用each; standDetail表明冒號後面的數組;用${standDetail.key}方式取每一個屬性的值; standDetailStat 默承認以不寫,不寫時自動默認爲standDetail+stat這個是固定的, standDetailStat裏有三個屬性:size : 數組的長度 index : 數組的索引值(默認從0開始) count : 數組的序號(默認從1開始)ip
8.三目運算 (此例中,comClass爲公共的,即不管是否條件爲true,此class都存在;)ci
<div th:class="*{infoAuditStatus} == 1? 'notAbleSubmit comClass':'ableSubmit comClass'"> <span>提交審覈</span> </div>
9.選擇/星號表達式 *{……} 選擇表達式通常跟在th:object後,直接取object中的屬性
<div th:object="${session.user}"> <p>Nationality: <span th:text="*{nationality}">Saturn</span>.</p> </div>