phi*_*e.b 43 spring-mvc thymeleaf
我试图了解如何遍历Thymeleaf中的Map中的所有条目.我有一个由Thymeleaf处理的域对象,其中包含一个Map.
如何循环键并获取值?
谢谢.
phi*_*e.b 98
没关系......我发现了......
<tr th:each="instance : ${analysis.instanceMap}">
<td th:text="${instance.key}">keyvalue</td>
<td th:text="${instance.value.numOfData}">num</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
谢谢.
ACV*_*ACV 29
如果您有一个List作为值.例如,如果您有一个地图,其中key是类别,而value是与该类别相关的项目列表,则可以使用以下命令:
<table>
<tr th:each="element : ${catsAndItems}">
<td th:text="${element.key}">keyvalue</td>
<table>
<tr th:each="anews : ${element.value}">
<td th:text="${anews.title}">Some name</td>
<td th:text="${anews.description}">Some name</td>
<td th:text="${anews.url}">Some name</td>
<td th:text="${anews.logo}">Some name</td>
<td th:text="${anews.collectionDate}">Some name</td>
</tr>
</table>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
43147 次 |
最近记录: |