一、倒序遍历数组对象
<td th:each="item :*{arrlist}">
<h4 type="text" th:text="*{item.message}"></h4>
</td>
<td th:each =" index: ${#numbers.sequence(arrlist.size()-1, 0, -1)}">
<h4 type =" text" th:text =" $ {arrlist[index] .message}">< / h4>
</td>
二、倒序输出数字 例如从100开始.......到 1 结束,每次-1
<td th:each="i : ${#numbers.sequence(100 , 1, -1)}">
<h4 type="text" th:text="${i}"></h4>
</td>
需要用thymeleaf
的内置函数了:#numbers.sequence
这个方法就是根据传入的参数生成一个数列,类似于java
的for
循环一样,支持两个参数和三个参数的
参数一:起始值(包含) 例如: arrlist.size()-1 即数组的最后一位
参数二:终点值(包含) 例如:下标为0,即数组的第一位
参数三:步长 例如:每隔1循环一次,类似 i--