私のJava spring mvc Webアプリケーションでは、リクエストパラメータをリンクに渡したいと思います。以下は、以下のコードの一部は「tempCustomer」の顧客IDを表示fine..It完璧に動作の.jspページのコードの一部 `<c:param> value属性が正しく動作しません
<c:url var = "updateLink" value="/customer/showFormForUpdate">
<c:param name="customerId" value="${tempCustomer.id}"></c:param>
</c:url>
<c:forEach var="tempCustomer" items="${customers}">
<tr>
<td> ${tempCustomer.firstName} </td>
<td> ${tempCustomer.lastName} </td>
<td> ${tempCustomer.email} </td>
<td> ${tempCustomer.id} </td>
<td> <a href="${updateLink}">Update</a> </td>
です。
<td> ${tempCustomer.id} </td>
しかし、
<c:url var = "updateLink" value="/customer/showFormForUpdate">
<c:param name="customerId" value="${tempCustomer.id}"></c:param>
コードdoesntの作業罰金のこの部分。 value = "$ {tempCustomer.id}"は単にtempCustomer.idの値を渡しません。私は
<td> <a href="${updateLink}">Update</a> </td>
、更新リンクをクリックすると、URLは、パラメータ値が存在しないこの
http://localhost:8080/web-customer-tracker/customer/showFormForUpdate?customerId=
のように見えます。 urlには、customerIdパラメータの値が格納されています。 forEachの:完全なリファレンスについては
は、ここでフルの.jspページのコードは、あなたがあなたのCでtempCustomer変数を定義し
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title>List Customers</title>
<link type="text/css" rel="stylesheet"
href="${pageContext.request.contextPath}/resources/css/style.css"/>
</head>
<body>
<div id ="wrapper">
<div id ="header">
<h2>CRM - Customer Relationship Manager</h2>
</div>
</div>
<div id ="container">
<div id = "content">
<input type="button" value="Add Customer"
onclick="window.location.href='showFormForAdd';return false;"
class="add-button" />
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
<!-- ${tempCustomer.id}
-->
<c:url var = "updateLink" value="/customer/showFormForUpdate">
<c:param name="customerId" value="${tempCustomer.id}"></c:param>
</c:url>
<c:forEach var="tempCustomer" items="${customers}">
<tr>
<td> ${tempCustomer.firstName} </td>
<td> ${tempCustomer.lastName} </td>
<td> ${tempCustomer.email} </td>
<td> ${tempCustomer.id} </td>
<td> <a href="${updateLink}">Update</a> </td>
</c:forEach>
</table>
</div>
</div>
</body>
</html>
ありがとうございます。それはそんなふうに間違いだった! –
私たちの最善を尽くす;-) –