Spring Boot Thymeleaf 循环遍历
Spring Boot Thymeleaf 大约 452 字th:each
${posts}
是从Controller
中的Model
对象中添加进来的,使用th:each
进行遍历,post
是临时变量。
<ul th:each="post : ${posts}">
<li>
<a th:text="${post.title}" th:href="|/p/${post.id}.html|"></a>
</li>
</ul>
for 循环
使用#numbers.sequence
生成Integer[]
数组,然后对数组进行th:each
遍历。count
是传入的变量。
场景:遍历1..10
,取数字1
到10
。
<th:block th:each="index: ${#numbers.sequence(1, count)}">
<div th:text="${index}"></div>
</th:block>
阅读 104 · 发布于 2023-08-18
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
OpenResty 整合 LuaRocks - Linux阅读 2660
-
IDEA 去除 Unchecked cast from Object to 提示阅读 3665
-
MySQL 内置函数之时间函数阅读 1905
-
Docker 同步宿主机时区阅读 459
-
Vue2 生命周期阅读 388
-
Kubernetes Ingress 控制器 Nginx阅读 1217
-
HTTP Content-Type 为 application/x-www-form-urlencoded 时注意事项阅读 2908
-
使用 ffmpeg 转换 m4a 为 mp3阅读 7557
-
设计模式之命令模式阅读 1242
-
定时清理 MongoDB 历史数据阅读 4207