我有一个HashMap
(称为test
),格式如下:HashMap<String,List<MyClass>>
。
我想将HashMap
值的项目显示为可扩展的标题,从中可以找到列表中每个对象的信息。
我有以下代码,但是在扩展列表中看到的只是每个标题一行。实际上,列表中的项目会被for循环中的下一个覆盖。
<tbody>
<tr th:each="element, iterStat : ${test}">
<td data-toggle="collapse" th:attr="data-target=|#demo${iterStat.count}|" th:text="${element.key}">keyvalue</td>
<tr class="accordian-body collapse" th:id="'demo' + ${iterStat.count}" th:each="anews : ${element.value}">
<td th:text="''">Place name</td>
<td th:text="${anews.first_point}">First point</td>
<td th:text="${anews.second_point}">Second point</td>
</tr>
</tr>
</tbody>
我应该如何更正我的代码?
这是您想要的吗?
<tbody>
<th:block th:each="element, iterStat : ${test}">
<tr>
<td colspan="3" data-toggle="collapse" th:data-target="|.demo${iterStat.count}|" th:text="${element.key}" />
</tr>
<tr class="accordian-body collapse" th:class="'demo' + ${iterStat.count}" th:each="anews : ${element.value}">
<td th:text="''">Place name</td>
<td th:text="${anews.first_point}" />
<td th:text="${anews.second_point}" />
</tr>
</th:block>
</tbody>