Ausgabe
Haben Sie etwas für:
for(int i = 0; i < ids.size(); i++){
List<NomenclatureTypeFirst> nmtf = nomenclatureTypeFirstService.getAllByRequest(ids.get(i));
map.put(ids.get(i), nmtf);
}
Versucht, th:text auf Wert wie folgt zu verwenden:
<table>
<tr th:each="entry, stats : ${map}">
<td th:text="${entry.key}"></td>
<td th:text="${entry.value.detname}"></td>
</tr>
</table>
Aber fangen:
Property or field 'detname' cannot be found on object of type 'java.util.ArrayList' - maybe not public or not valid?
Wie kann ich das machen?
Lösung
Der Wert Ihrer Karte ist eine Liste, also müssen Sie über die Werte iterieren:
<table>
<tr th:each="entry, stats : ${map}">
<td th:text="${entry.key}"></td>
<table>
<tr th:each="value : ${entry.value}">
<td th:text="${value.detname}"></td>
</tr></table>
</tr>
</table>
Beantwortet von – Jens
Antwort geprüft von – Gilberto Lyons (FixError Admin)