【发布时间】:2018-02-19 14:40:21
【问题描述】:
在我使用 spring 和 thyme-leaf 执行的 Web 应用程序中,我的数据库中有一个表,我需要由用户更新它。在我的表格的行下方找到。
<table class="table table-responsive">
<thead>
<tr>
<th>From <a href="#"><i class="fa fa-sort-amount-asc"
aria-hidden="true"></i></a></th>
<th>To <a href="#"><i class="fa fa-sort-amount-asc" aria-hidden="true"></i></a>
</th>
<th>th1(.min)</th>
<th>th2</th>
<th>th3</th>
<th>th4 ❯</th>
<th>th5</th>
<th>th6</th>
<th>th7</th>
<th class="action"> </th>
</tr>
</thead>
<tbody>
<tr th:each="ir, rowStat : *{invRows}">
<input type="hidden"
th:field="*{invRows[__${rowStat.index}__].fromTime}"/>
<input type="hidden" th:field="*{invRows[__${rowStat.index}__].toTime}"/>
<td><p th:text="${#dates.format(ir.fromTime, 'HH:mm')}"/></td>
<td><p th:text="${#dates.format(ir.toTime, 'HH:mm')}"/></td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].tvcDur}"/></td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].priceR[0].price}"/>
</td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].priceR[1].price}"/>
</td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].priceR[2].price}"/>
</td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].lgPrice}"/></td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].crPrice}"/></td>
<td><input type="text"
th:field="*{invRows[__${rowStat.index}__].crSpots}"/></td>
<td class="actions"></td>
</tr>
</tbody>
</table>
参数与mysql数据库绑定成功。但问题是每次保存表时都会一次又一次地添加整组行,而不是更新行的现有值。如何更新表格?
编辑: 我有以下下拉列表。对于每个选择,我都想要一张桌子。即我必须维护 3 张桌子。如何做到这一点?
<select class="btn btn-default dropdown-toggle" data-toggle="dropdown"
th:value = "${inventory.id}" id="channel" name="channel">
<option th:value="Channel">Channel</option>
<option th:value="ch1">ch1</option>
<option th:value="ch2">ch2</option>
<option th:value="ch3">ch3</option>
</select>
【问题讨论】:
-
您应该在表格中添加元素“ir”的 id 作为隐藏字段。像这样
-
这里的“id”是什么?
标签: java html mysql spring thymeleaf