thymeleaf使用之多变量
<div>迭代状态对象</div>
<table>
<tr th:each="data,iterState : ${#numbers.sequence(0,2)}"
th:style="|background-color:| + ${iterState.odd ? 'while' : 'gray'}">
<td th:text="|从0开头的索引:| + ${iterState.index}"></td>
<td th:text="|从1开头的索引:| + ${iterState.count}"></td>
<td th:text="|数据集合大小:| + ${iterState.size}"></td>
<td th:text="|当前节点:| + ${iterState.current}"></td>
<td th:text="|是否第一次迭代:| + ${iterState.first}"></td>
<td th:text="|是否最后一次迭代:| + ${iterState.last}"></td>
<td th:text="|是否偶数迭代:| + ${iterState.even}"></td>
<td th:text="|是否奇数迭代:| + ${iterState.odd}"></td>
</tr>
</table>
要将文本和变量进行组合,使用如:
托尔斯泰+'${user}'
还有链接的变量拼接
<dl class="layui-nav-child" th:each="reci,reciStat : ${recis}">
<dd><a th:href="@{'/ar/'+${reciStat.index}}" th:text="${reci.keyword}+'('+${reci.number}+')'" target="frame"></a></dd>
</dl>

浙公网安备 33010602011771号