Reputation: 2292
How can I rewrite the script below with out specifying the index[x]? and allow thymeleaf to iterate the whole list to see if it find a match of test.host == server.host.
<tr th:if="${server.host == test[1].host}">
<td th:text ="${test[1].Status}"></td>
<td th:text="${test[1].host}"></td>
<td th:text="${test[1].version}"></td>
</tr>
It's not working the way I wanted it to work. It worked when I used index[x] to specify a host. I wanted it to iterate through the whole list. If test.host matches server.host. I don't want to specify an index[x]
Upvotes: 0
Views: 1416
Reputation: 3727
I think you can iterate using th:each
on your collection/ array
<th:block th:each="item: ${test}">///item is a var name, test is your array
<tr th:if="${server.host == item.host}">
<td th:text="${item.Status}"></td>
<td th:text="${item.host}"></td>
<td th:text="${item.version}"></td>
</tr>
</th:block>
Upvotes: 1