thymeleaf循环

th:each属性用于迭代循环,语法:th:each="obj,iterStat:${objList}"
迭代对象可以是Java.util.List,java.util.Map,数组等;
iterStat称作状态变量,属性有:
index:当前迭代对象的index(从0开始计算)
count: 当前迭代对象的index(从1开始计算)
size:被迭代对象的大小
current:当前迭代变量
even/odd:布尔值,当前循环是否是偶数/奇数(从0开始计算)
first:布尔值,当前循环是否是第一个
last:布尔值,当前循环是否是最后一个

循环MAP时取值

${map['key']}

MAP,VALUE为List<String>集合时遍历方法

<ul th:each="lm : ${classNames}">
     <li th:each="entry : ${lm}" th:text="${entry.key}"></li>
     <select>
         <option th:each="entry : ${lm.value}" th:text="${entry}" ></option>
     </select>
</ul>
原文地址:https://www.cnblogs.com/zhanchaohan/p/10081235.html