-1
在我的Java spring mvc web应用程序中,我想在链接中传递请求参数。下面是一个的.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>
下面的代码的部分工作完全fine..It显示客户的ID为“tempCustomer”的部分。
<td> ${tempCustomer.id} </td>
然而,
<c:url var = "updateLink" value="/customer/showFormForUpdate">
<c:param name="customerId" value="${tempCustomer.id}"></c:param>
的代码不工作精细这一部分。值=“$ {tempCustomer.id}”只是不传递tempCustomer.id的值。当我点击,更新链接
<td> <a href="${updateLink}">Update</a> </td>
的URL看起来像这样
http://localhost:8080/web-customer-tracker/customer/showFormForUpdate?customerId=
参数值是不存在的。 url应该包含customerId参数的值。
对于完整的参考,这里是全的.jsp页面代码
<%@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>
谢谢大声笑。这是一个小白菜错误! –
发生在我们身上;-) –