jsp - <c:param> value attribute not working properly -
in java spring mvc web app, want pass request parameter in link. following portion of .jsp page code `
<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>
the portion of code below works fine..it displays customer id 'tempcustomer'.
<td> ${tempcustomer.id} </td>
however,
<c:url var = "updatelink" value="/customer/showformforupdate"> <c:param name="customerid" value="${tempcustomer.id}"></c:param>
this portion of code doesnt work fine. value="${tempcustomer.id}" doesn't pass value of tempcustomer.id. when click, update link
<td> <a href="${updatelink}">update</a> </td>
the url looks
http://localhost:8080/web-customer-tracker/customer/showformforupdate?customerid=
the parameter value absent. url supposed contain customerid parameter's value.
for complete reference, here full .jsp page code
<%@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>
<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>
you defined tempcustomer variable in c:foreach. exists in scope of c:foreach. move c:url block under c:foreach.
Comments
Post a Comment