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:

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

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>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top