I tried using th:remove="all-but-first" in thymeleaf but it didn't work -
<td th:remove="all-but-first"> <span th:each="groups : ${userview.user.groupmemberships}"> <span th:text="${groups.group.name}"></span>; </span> </td>
i trying display first 2 rows returned in th:each
, tried displaying first row @ first , didn't work.
how display first row , should if want display first 2 or 3 rows in th:each
?
the attribute th:remove
used removing prototyping generated tags.
as example:
<table th:remove="all-but-first"> <tr th:each="user : ${users}"> <td th:text="${user.name}">john apricot</td> </tr> <tr> <td>martha apple</td> </tr> <tr> <td>frederic orange</td> </tr> </table>
this means remove second , third tr
, leaving tr
used iteration. more details here.
so if want display first element of collection, there no need perform iteration, access index (or key if it's map).
example:
<td> <span th:text="${userview.user.groupmemberships[0].group.name}"></span> </td>
Comments
Post a Comment