1. 程式人生 > >Thymeleaf 模板標籤使用

Thymeleaf 模板標籤使用

1.th:text 賦值

<td  th:text="${balanceRepair.workOrderInfo.userPhone}"></td>

2. #dates.format(date,'yyyy-MM-dd') 日期格式化 

th:text="${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd')}" ; 

${#dates.format(new java.util.Date().getTime(), 'yyyy年MM月dd日HH時mm分')}"

3. 金額格式化

th:text="${workOrderProject.workingPrice} ? ${#numbers.formatDecimal(workOrderProject.workingPrice,1,'COMMA',2,'POINT')}:''"

4.遍歷   th:each="workOrderPart,workOrderPartStat : ${balanceRepair.workOrderParts}"  workOrderPartStat 固定 workOrderPart引數+Stat 

<tr th:each="workOrderPart,workOrderPartStat : ${balanceRepair.workOrderParts}">
                <td th:text="${workOrderPartStat.index+1}"></td>
                <td th:text="${workOrderPart.partName}"></td>
                <td th:text="${workOrderPart.brandName}"></td>
                <td th:text="${workOrderPart.count}"></td>
                <td th:text="${workOrderPart.unitPrice} ? ${#numbers.formatDecimal(workOrderPart.unitPrice,1,'COMMA',2,'POINT')}:''"></td>
                <td th:text="${workOrderPart.partAmount} ? ${#numbers.formatDecimal(workOrderPart.partAmount,1,'COMMA',2,'POINT')}:''"></td>
            </tr>