日期:2014-05-16 浏览次数:20700 次
<script type="text/javascript"> $(document).ready(function(){ $("#district_id").change(function(){ var district_id=$("#district_id").val(); //alert(district_id); $.post("streetList.action",{districtId:district_id},function callBack(data){ var bb=eval("("+data+")"); alert(bb); },'json'); }); }); </script>
<package name="default" extends="json-default"> <action name="streetList" class="com.accp.houserent.action.HouseAction" method="streetList"> <result type="json"><param name="root">result</param></result> </action> </package>
/** * 获得街道列表 */ public String streetList() throws Exception { // TODO Auto-generated method stub HttpServletRequest request = getHttpServletRequest(); try { CommonBiz commonBiz = new CommonBizImpl(); String districtId = request.getParameter("districtId"); District district = commonBiz.getEntity(District.class, Integer.parseInt(districtId)); // System.out.println(district.getStreets().size()); Map<String, Street> map = new HashMap<String, Street>(); Iterator<Street> it = district.getStreets().iterator(); while (it.hasNext()) { Street street = it.next(); map.put(street.getStreetName(), street); } result =map; } catch (Exception e) { e.printStackTrace(); } return SUCCESS; } private Map<String, Street> result; public Map<String, Street> getStreets() { return result; } public void setStreets(Map<String, Street> result) { this.result = result; }