需求:
输出5个li
编码参考:
<ul>
<li th:each="index:${#numbers.sequence(1, 5)}" >
[(${index})]. some thing
</li>
</ul>
执行结果:
<ul>
<li>
1. some thing
</li>
<li>
2. some thing
</li>
<li>
3. some thing
</li>
<li>
4. some thing
</li>
<li>
5. some thing
</li>
</ul>
根据数组长度循环输出li
<ul th:with="liSize=5">
<li th:each="index : ${#numbers.sequence(1, liSize)}" >
[(${index})]. some thing
</li>
</ul>
执行结果:
<ul>
<li>
1. some thing
</li>
<li>
2. some thing
</li>
<li>
3. some thing
</li>
<li>
4. some thing
</li>
<li>
5. some thing
</li>
</ul>
https://www.leftso.com/article/2408061448498694.html