Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting data in <tr> with thymeleaf

Tags:

thymeleaf

This is my code fragment:

<th:block th:each="d : ${items}">
    <!--<tr>-->
        <td th:text="${d.productname}"></td>
        <td th:text="${d.quantity}"></td>
        <td th:text="${d.price}"></td>
    <!--</tr>-->
</th:block>

items is an ArrayList.
I can get data if the tr doesn't exist (as you can see I commented it in the code).
If I put them back, my th:text gets null values. I also tried tr th:each but it didn't help.

How can I solve this problem? Thank you.

like image 694
Nguyễn Bá Lê Huyên Avatar asked May 27 '26 06:05

Nguyễn Bá Lê Huyên


1 Answers

I am using thymeleaf-3.0.0 ,It worked for me.

    <table>
    <tr th:each="d : ${items}" >
                <td th:text="${d.productname}"></td>
                <td th:text="${d.quantity}"></td>
                <td th:text="${d.price}"></td>
    </tr>
    </table>
like image 63
akreddy.21 Avatar answered Jun 03 '26 01:06

akreddy.21



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!