how do you find a specific element and get a field value from a list of objects in thymeleaf?

The expression is simply: ${protocolVersions.^[id==1007].name}. So you could do this in your table:

<tr>
  <td th:text="${protocolVersions.^[id==1007].name}"></td>
</tr>

If you want to check against a variable, rather than hardcoding 1007 something like this:

<th:block th:with="check=1007">
  <td th:text="${protocolVersions.^[id==#root.check].name}"></td>
</th:block>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top