2015-04-05 96 views
0

在我的第一個jsp中,我使用Google API獲取附近商店及其他屬性(如商店名稱,緯度,經度等)的列表。通過鏈接將值從一個jsp傳遞給另一個jsp

在我的第二個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")%> 

回答

0

你的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正確讀取了請求參數。

+0

謝謝你運作得很好... – Dev 2015-04-05 21:35:00

相關問題