我正在使用 Spring Roo 和 jspx 来制作一个用于管理房地产投资组合的系统。
在我的“propertys/show.jspx”文件中,我使用 Google Maps API 嵌入了地图,现在我希望将属性的邮政编码/邮政编码传递到地理编码方法中,以在地图上显示属性的位置。
我对 jsp(x) 比较陌生,但是我尝试了各种选项,例如使用邮政编码“id”值或使用 ${property.postcode}/${property.getPostcode()},但这些都不起作用。当然,我正在尝试做的事情是可能的,我已经在网上搜索了几个小时,但一直在努力寻找任何有帮助的东西。
这是我的代码:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:embed="urn:jsptagdir:/WEB-INF/tags/embed" xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:page="urn:jsptagdir:/WEB-INF/tags/form" xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<page:show id="ps_propertymodule_model_Property" object="${property}" path="/propertys" z="WKsfPr4ho5x13a9S80pO1Z6yVzU=">
<table width="100%;">
<tr>
<td width="60%">
<field:display field="propertyNameNumber" id="s_propertymodule_model_Property_propertyNameNumber" object="${property}" z="DRkvOGCjByMk2N7UunO4fD8LJfc="/>
<field:display field="streetName" id="s_propertymodule_model_Property_streetName" object="${property}" z="caugN9DlFqoZLN+WEKIjaJEQUSI="/>
<field:display field="townCity" id="s_propertymodule_model_Property_townCity" object="${property}" z="Fp+KSaGrgdbXhRzllkBo9FxmXIM="/>
<field:display field="county" id="s_propertymodule_model_Property_county" object="${property}" z="mmJB81/8iBFbt+jXICA9q8xCDHw="/>
<field:display field="postcode" id="s_propertymodule_model_Property_postcode" object="${property}" z="j1qr8EujBkOLnsX1vcgFaPlEWtU="/>
<br/>
<br/>
<field:display date="true" dateTimePattern="${property_datepurchased_date_format}" field="datePurchased" id="s_propertymodule_model_Property_datePurchased" object="${property}" z="B22znN56FtmM/zueTwnOcjNl83k="/>
<field:display field="pricePaid" id="s_propertymodule_model_Property_pricePaid" object="${property}" z="CQLyDqQhFtqoYfMusAB/XeA+wW0="/>
<field:display field="stampDuty" id="s_propertymodule_model_Property_stampDuty" object="${property}" z="x7sgRlL8ROhdb9MonWP33N4Ishs="/>
<field:display field="legalCost" id="s_propertymodule_model_Property_legalCost" object="${property}" z="TH0DgdlKfeFDefSgq+HDVebcxm0="/>
<field:display field="agentFee" id="s_propertymodule_model_Property_agentFee" object="${property}" z="05bXxWqJcMzgbwtVBHUujPWU7ZA="/>
<br/>
<br/>
<field:display field="area" id="s_propertymodule_model_Property_area" object="${property}" z="Eb5a0xmk5qSFaKZ3BYMGR7lNYw8="/>
<field:display field="salePrice" id="s_propertymodule_model_Property_salePrice" object="${property}" z="cQHnoPj/QNnb2XwRclq6n4zR+gs="/>
<field:display field="saleCommission" id="s_propertymodule_model_Property_saleCommission" object="${property}" z="ULPRSdiwV/tk+kS59uyk16TkcoY="/>
<field:display field="legalExpenses" id="s_propertymodule_model_Property_legalExpenses" object="${property}" z="/a0+xD2IyDttEZpI9zlcOpruOaQ="/>
<field:display field="comments" id="s_propertymodule_model_Property_comments" object="${property}" z="RDKzYGFdOQUXNcAhV3/JGF8v7V0="/>
<field:display field="image" id="s_propertymodule_model_Property_image" object="${property}" z="TBQCQkvQcyTDVJQw7l95WI6zt9U="/>
<field:display field="vacant" id="s_propertymodule_model_Property_vacant" object="${property}" z="03Pa/jpb5PtZRPMAQzLryud0dBs="/>
<c:set var="post_code" value="${property.postcode}" />
</td>
<td>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBQaHw1aSWtIjQzAiriBPC3hvm7Bs1R35U&sensor=false"><jsp:text></jsp:text></script>
<script type="text/javascript">
//<![CDATA[
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(51.10,-0.84),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
codeAddress();
}
function codeAddress() {
var address = document.getElementById(address).value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
// ]]>
</script>
<div id="map_canvas" style="width: 250px; height: 250px"></div>
</td>
</tr>
</table>
</page:show>
</div>
如果有人能给我任何提示或提示,我将不胜感激,因为我真的认为这是一个基本问题,而且无法解决它真的让我很沮丧!
谢谢
史蒂夫