[英]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.