Home > Enterprise >  Why does my th:each not work in my div? Thymleaf
Why does my th:each not work in my div? Thymleaf

Time:12-30

I'm trying to th:text in my div but it doesnt seem to work

I tried doing it with a table and i get the data i need but when i put it in a div it doesnt work

     <div   data-th-each="shoes: ${shoesList}">
          <p th:text="$(shoes.name)"></p>
          <p th:text="$(shoes.description)"></p>
          <p th:text="$(shoes.price)"></p>          
      </div>

This works tho

<table>

      <tr data-th-each="shoes : ${shoesList}">    
        <td th:text="${shoes.name}"></td>
        <td th:text="${shoes.description}"></td>
        <td th:text="${shoes.price}"></td>
      </tr>        
  
</table>

CodePudding user response:

I think, it will be following way ( correct $(shoes.name) to ${shoes.name} )

<div   th:each="shoes : ${shoesList}">
      <p th:text="${shoes.name}"></p>
      <p th:text="${shoes.description}"></p>
      <p th:text="${shoes.price}"></p>          
  </div>

Please visit this link Iteration thymeleaf

  • Related