我有这个index.jsp文件,其中显示了所有项目列表,并且可以 通过单击项目名称来更新>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/pages/commons/scripts.jsp"%>
<title>Pabebe Inventory Store</title>
</head>
<body>
<c:if test="${not empty success}">
<script type="text/javascript">
alert("Item successfully added.");
</script>
<c:remove var="success" scope="request" />
</c:if>
<c:choose>
<c:when test="${not empty user}">
Hi <c:out value="${user.firstName}" />!<br>
<a href="LogOut">Logout</a>
<a href="AddItem">Add new item</a>
</c:when>
<c:otherwise>
Hello please click <a href="Login">Login</a>
</c:otherwise>
</c:choose>
<table>
<tr>
<td>
<form id="searchItem" method="POST" action="ItemList">
<input type="text" id="searchkeyword" name="searchkeyword"
value="<c:out value="${searchkeyword}"/>" /><input type="submit"
value="Search" />
</form>
</td>
<td>
<form id="resetItem" method="GET" action="ItemList">
<input type="submit" value="Reset" />
</form>
</td>
</tr>
</table>
<table border=1>
<thead>
<tr>
<th>Item Name</th>
<th>Item Description</th>
<th>Item Price</th>
<th>Item Quantity</th>
<c:if test="${not empty user}">
<th>Action</th>
</c:if>
</tr>
</thead>
<tbody>
<c:forEach items="${items}" var="items">
<tr>
<td><c:choose>
<c:when test="${not empty user}">
<a href="UpdateItem?id=<c:out value="${items.id}"/>"><c:out
value="${items.itemName}" /></a>
</c:when>
<c:otherwise>
<c:out value="${items.itemName}" />
</c:otherwise>
</c:choose></td>
<td><c:out value="${items.itemDescription}" /></td>
<td><c:out value="${items.itemPrice}" /></td>
<td><c:out value="${items.itemQuantity}" /></td>
<c:if test="${not empty user}">
<td>
<form id="deleteItem<c:out value="${items.id}"/>" method="POST"
action="DeleteItem">
<input type="hidden" id="id" name="id"
value="<c:out value="${items.id}"/>" /> <input type="submit"
value="Delete"
onclick="return confirm('Are you sure to delete this item?')" />
</form>
</td>
</c:if>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
当点击项目名称时,我有另一个jsp文件,它是&gt; itemUpdate.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/pages/commons/scripts.jsp"%>
<title>Pabebe Inventory Store</title>
</head>
<body>
<form action="UpdateItem" method="POST">
<table align="center" width="400px">
<tr>
<td>Item name</td>
<td><input type="text" id="itemname" name="itemname"
value="<c:out value="${itemname}"/>" /></td>
<td><c:out value="${usernameerrmsg}" /></td>
</tr>
<tr>
<td>Item description</td>
<td><input type="text" id="itemdescription"
name="itemdescription" value="<c:out value="${itemdescription}"/>" /></td>
<td><c:out value="${usernameerrmsg}" /></td>
</tr>
<tr>
<td>Item price</td>
<td><input type="text" id="itemprice" name="itemprice"
value="<c:out value="${itemprice}"/>" /></td>
<td><c:out value="${usernameerrmsg}" /></td>
</tr>
<tr>
<tr>
<td>Item quantity</td>
<td><input type="text" id="itemquantity" name="itemquantity"
value="<c:out value="${itemquantity}"/>" /></td>
<td><c:out value="${usernameerrmsg}" /></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit"
value="Submit" /></td>
</tr>
</table>
</form>
<a href="ItemList">Go to item list</a>
</body>
</html>
我的问题是,如何在&gt; itemUpdate.jsp中的输入文本中显示所点击项目的当前值?当我更改文本并单击&gt;提交按钮时,数据库中的值仍将更新。顺便说一句,我的更新是>正常工作。我只想在&gt;我要更新特定项目时在文本框中显示当前值。