显示嵌套对象

时间:2018-04-15 12:40:10

标签: thymeleaf

我使用带百里香的弹簧靴,在页面中尝试显示一个表格,它是嵌套对象。

我的对象工厂

  • id
  • 姓名
  • 列表

当我显示

<form id="factoriesForm" th:object="${factories}" >
   ...
   ...
   <table id="machinesTable" class="table table-striped table-hover responsive">
      <thead>
         <tr>
            <th th:text="#{name}">Name</th>
            <th th:text="#{description}">Description</th>
            <th></th>
         </tr>
      </thead>
      <tbody>
         <tr th:each="machine, stat : ${machines}">
            <td> 
               <input type="hidden" th:id="${'machineId-'+stat.index}"  th:field="*{machines[__${stat.index}__].id}" />
               <input type="text" class="form-control" th:id="${'machineName-'+stat.index}" th:placeholder="#{name.placeholder}" placeholder="Name" th:field="*{machines[__${stat.index}__].name}" />
            </td>
            <td> <input type="text" class="form-control" th:id="${'machineDescription-'+stat.index}" th:placeholder="#{description.placeholder}" placeholder="Description" th:field="*{machines[__${stat.index}__].description}" /></td>
            <td> <i class="fas fa-trash-alt"></i></td>
         </tr>
      </tbody>
   </table>
</form>

我的工厂有很多机器,但没有显示

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

更改

$ {工厂}

* {工厂}