我正在使用Spring Roo和jspx建立一个管理房地产投资组合的系统。
在我的“propertys / show.jspx”文件中,我使用Google Maps API嵌入了地图,现在我希望将属性的post / zip代码传递到地理编码方法,以显示属性的位置地图。
我对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>
如果有人能给我任何可以提及的提示或提示,因为我认为这是一个基本问题而且我无法解决它真的很令人沮丧!
由于
史蒂夫
答案 0 :(得分:0)
如果您查看display.tagx,您可以看到如下所示的对象值:
<spring:eval expression="object[field]" />
据推测,你应该能够使用这是你的jspx:
来访问邮政编码<spring:eval expression="property[postcode]" />
例如:
<script type="text/javascript">
//<![CDATA[
var map;
var post_code = <spring:eval expression="property[postcode]" />;
...