Skip to content Skip to sidebar Skip to footer

Thymeleaf Format For List Within A Hashmap

I'm trying to put template which has a list of values within a key in a hashmap, However when I try to put it into the template if falls over into new row by itself. Picture: Thy

Solution 1:

You're creating <tr />s in your <tr />s. Looking at the source generated by thymeleaf should tell you this. I would guess your html should look something like this:

<table class="table table-striped">
  <tr>
    <th>Board Name</th>
    <th>Investor</th>
    <th>Fuse Manufacturer</th>
    <th>Fuse Nr. Of Poles</th>
    <th>Fuse Characteritics</th>
    <th>Fuse Amount</th>
  </tr>

  <th:block th:each="item: ${map}">
    <tr th:each="fuse: ${item.value}">
      <td th:text="${item.key.name}" />
      <td th:text="${item.key.investor}" />
      <td th:text="${fuse.fuse.manufacturer.name}" />
      <td th:text="${fuse.fuse.type}" />
      <td th:text="${fuse.fuse.characteristics}" />
      <td th:text="${fuse.quantity}" />
    </tr>
  </th:block>
</table>

Post a Comment for "Thymeleaf Format For List Within A Hashmap"