springboot (four): detailed explanation of thymeleaf use

th:each iteration loop of using thymeleaf

The th:each attribute is used for iterative loops, syntax: th:each="obj,iterStat:${objList}"

The iterable object can be java.util.List, java.util.Map, array, etc.;

iterStat is called a state variable, and the properties are:

index: the index of the current iteration object (calculated from 0)

count: the index of the current iteration object (calculated from 1)

size: the size of the object being iterated

current: current iteration variable

even/odd: boolean, whether the current loop is even/odd (counting from 0)

first: boolean, whether the current loop is the first

last: boolean, whether the current loop is the last

<input type="hidden" th:id="totalCnt"  th:value="${userTotal}" />
<input type="hidden" th:id="pageIndex"  th:value="${pageIndex}" />
<input type="hidden" th:id="pageSize"  th:value="${pageSize}" />
<tr th:each="user,userStat:${userlist}">
    <th width="44px"><input type="checkbox" style="margin-left: 18px;" th:id="${user.id}"/></th>
    <td  th:text="${pageIndex}*${pageSize}+${userStat.count}"></td>
    <td th:text="${user.username}"></td>
    <td th:text="${user.email}"></td>
    <td th:text="${#dates.format(user.creattime, 'yyyy-MM-dd-hh:mm:ss')}"></td>
    <td th:text="${#dates.format(user.updatetime, 'yyyy-MM-dd-hh:mm:ss')}"></td>    
</tr>

 

 

 

https://www.cnblogs.com/huangjuncong/p/9026949.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324452494&siteId=291194637