简体   繁体   English

通过链接将值从一个jsp传递到另一个jsp

[英]Passing value from one jsp to another jsp via a link

In my first jsp i am getting a list of nearby stores and their other attributes like name of the store, latitude, longitude etc. using Google API. 在我的第一个jsp中,我使用Google API获取附近商店的列表及其其他属性,例如商店名称,纬度,经度等。

In my second jsp. 在我的第二个jsp中。 i want the latitude and longitude of the particular store that the user has selected from the list shown in first jsp. 我想要用户从第一个jsp中显示的列表中选择的特定商店的纬度和经度。

I am trying to pass the values of latitude and longitude via href but somehow i cannot. 我试图通过href传递纬度和经度的值,但是我不知道如何。 below is my code: 下面是我的代码:

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) gives proper latitude and longitude but while passing this value, nothing appears on second page. place.geometry.location.toUrlValue(6)给出适当的纬度和经度,但是在传递此值时,第二页上没有任何内容。

Here's how i am retrieving the value in my second jsp: 这是我在第二个jsp中检索值的方式:

<%=request.getParameter("key")%>

Your html markup looks a little off to me. 您的html标记对我来说有点不足。 The closing apostrophe enclosing the href attribute is missing: 缺少包含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>";

You should check your generated source code and confirm that the href is valid. 您应该检查生成的源代码,并确认href有效。 Also, try going directly to second.jsp?key=test to confirm that your jsp is reading the request param correctly. 另外,尝试直接转到second.jsp?key=test以确认您的jsp是否正确读取了请求参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM