简体   繁体   中英

How do I use Thymeleaf th:each to print a list objects in divs, not <td>

I have a list of objects that I pass to a frontend JSP page. I need to display each value in its own div.

For example:

<div class="objects">
    <div class="object"></div>
    <div class="object"></div>
    <div class="object"></div>
    <div class="object"></div>
    ...
</div>

Is there any way to do it this way as opposed to putting it in a table and doing <td> ?

The list of Posts data can be printed as below in div

<div th:each="tempPost:${posts}">
     <div th:text="${tempPost.getContent()}"></div>
     <div th:text="${tempPost.getAuthor()}"></div>
     <div th:text="${tempPost.getCreatedAt()}"></div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM