thymeleaf使用之多变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < 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}'
还有链接的变量拼接
1 2 3 | < 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 > |
本文作者:durtime
本文链接:https://www.cnblogs.com/durtime/p/15616615.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2020-11-28 每日日报