I have a list of User objects, and I want to transform it to a list of names, join it, and present it (not in a table). How do I do it?
class User {
String name;
String address;
}
I have the usersList, and I want to transform it to the list of names, something like this:
<body>
<h1>Names of Users</h1>
<span>
<div th:text="${#strings.listJoin(usersList.map( u -> u.name).collect(Collectors.toList()), ',')}"></div>
</span>
</body>
how can I do it in thymeleaf?
You can do this with collection projection:
<body>
<h1>Names of Users</h1>
<span>
<div th:text="${#strings.listJoin(usersList.![name], ',')}" />
</span>
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With