嗨我有这样的表
id pname quanity Action
-----------------------------
1 mouse 1 update
2 keyboard 2 update
3 monitor 3 update
我想在点击更新后更新表格
我已经使用JSTL标签编写了代码..但它只更新了第一行。 我对jstl很新,任何人都可以帮助我吗?
<sql:setDataSource var="dbsource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/sample" user="root" password="sample" />
<sql:query dataSource="${dbsource}" var="result"> SELECT * from product ; </sql:query>
<form action="#" method="post">
<table border="0" width="40%">
<caption>Update Product</caption>
<tr>
<th>Product Name</th>
<th>Quantity</th>
</tr>
<c:forEach var="row" items="${result.rows}">
<tr>
<td><input type="hidden" value="${row.id}" name="id"/>
<input type="text" value="${row.pname}" name="pname"/></td>
<td><input type="text" value="${row.quantity}" name="qty"/></td>
<td><input type="submit" value="Update"/></td>
</tr>
</c:forEach>
</table>
<a href="index.jsp">Go Home</a>
</form>
<sql:update dataSource="${dbsource}" var="count">
UPDATE product SET pname = ?, quantity=? WHERE id='${param.id}'
<sql:param value="${param.pname}" />
<sql:param value="${param.qty}" />
</sql:update>
<c:if test="${count>=1}">
<font size="5" color='green'> Congratulations ! Data updated successfully.</font>
<a href="index.jsp">Go Home</a>
</c:if>