【发布时间】:2020-05-10 13:28:19
【问题描述】:
我在混合 JSP Servlet 和 c:forEach 表单时遇到问题... 问题是无论我的 id 是什么,HTML 表单总是会发送列表中的第一个,称为“name="id"”。 有没有办法获得几个 name="id1", name="id2" ...等等以获得好的?
这里是代码。
<div id="client-table">
<form action="gestion-commandes" method="POST">
<table class="table table-striped">
<thead class="thead-custom">
<tr>
<th scope="col">#</th>
<th scope="col">NOM</th>
<th scope="col">PRENOM</th>
<th scope="col">EMAIL</th>
<th scope="col">TEL</th>
<th scope="col">COMMANDES</th>
</tr>
</thead>
<tbody class="tbody-custom">
<c:forEach items="${clients}" var="client">
<tr>
<th scope="col">${client.id}<input name="id" value="${client.id}" hidden = "true"></th>
<th scope="col">${client.nom}</th>
<th scope="col">${client.prenom}</th>
<th scope="col">${client.email}</th>
<th scope="col">${client.tel}</th>
<th scope="col"><button type="submit">Commandes</button>
</th>
</tr>
</c:forEach>
</tbody>
</table>
</form>
</div>
</div>
提前谢谢你, 乔斯
【问题讨论】:
-
您需要获取所有 id 吗?还是只有特定的一个?
标签: html forms jsp servlets foreach