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>