[英]Passing value from one jsp to another jsp via a link
在我的第一个jsp中,我使用Google API获取附近商店的列表及其其他属性,例如商店名称,纬度,经度等。
在我的第二个jsp中。 我想要用户从第一个jsp中显示的列表中选择的特定商店的纬度和经度。
我试图通过href传递纬度和经度的值,但是我不知道如何。 下面是我的代码:
side_bar_html += "<tr><td>" + place.geometry.location.toUrlValue(6) + "</td><td><a href='second.jsp?key='+place.geometry.location.toUrlValue(6)>" + "LINK" + "</a></td></tr>";
place.geometry.location.toUrlValue(6)
给出适当的纬度和经度,但是在传递此值时,第二页上没有任何内容。
这是我在第二个jsp中检索值的方式:
<%=request.getParameter("key")%>
您的html标记对我来说有点不足。 缺少包含href属性的右撇号:
side_bar_html += "<tr><td>" + place.geometry.location.toUrlValue(6) + "</td><td><a href='second.jsp?key=" + place.geometry.location.toUrlValue(6) + "'>" + "LINK" + "</a></td></tr>";
您应该检查生成的源代码,并确认href有效。 另外,尝试直接转到second.jsp?key=test
以确认您的jsp是否正确读取了请求参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.