【发布时间】:2020-12-15 19:30:58
【问题描述】:
如何使用 Thymleaf 访问 HTML 中对象中包含的列表变量
例如:aClient 的所有属性都是 String 对象。它们可以被访问为
<tr th:each="aClient : ${clientList}">
<td th:text="${aClient.firstName}"/>
<td th:text="${aClient.lastName}"/>
<td th:text="${aClient.address}"/>
<td th:text="${aClient.clientType}"/>
但是对于像这样的财产
List<Service> services.
如何访问它?
在阅读后尝试在下面做。但它没有提取服务的名称。
<div th:each="service, serv : *{services}">
<input type="text" th:field="*{service[__${serv.index}__].name}" />
</div>
“name”是Service类中带有getter和setter的属性。
【问题讨论】:
标签: spring spring-boot thymeleaf