Java thymileaf:在遍历列表时从映射中获取值
我试图在遍历列表时从映射中获取值<代码>搜索结果包含一个Java thymileaf:在遍历列表时从映射中获取值,java,spring-mvc,thymeleaf,Java,Spring Mvc,Thymeleaf,我试图在遍历列表时从映射中获取值搜索结果包含一个书籍对象列表,每个对象都有一个类别列表。 categoryFacetCounts是一个包含每个类别值计数的映射。该映射具有所有可能类别的值(我调试并检查) 下面是我的解决方案,它将null打印为地图的输出: <table class="table table-striped" id="watchlist-table"> <thead> <tr> <th>Name<
书籍
对象列表,每个对象都有一个类别列表。
categoryFacetCounts
是一个包含每个类别值计数的映射。该映射具有所有可能类别的值(我调试并检查)
下面是我的解决方案,它将null
打印为地图的输出:
<table class="table table-striped" id="watchlist-table">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Categories</th>
</tr>
</thead>
<tbody>
<tr th:each="book : ${searchResult}">
<td th:text="${book.name}"></td>
<td th:text="${book.description}"></td>
<td>
<span th:each="c : ${book.categories}">
<span th:text="${c} + '(' + ${categoryFacetCounts[__${c}__]} + ') '"></span>
</span>
</td>
</tr>
</tbody>
</table>
名称
描述
类别
使用地图的get
方法,categoryFaceCounts
希望这有帮助