日期:2014-05-16 浏览次数:20645 次
function getStreet(){ var district = document.getElementById("district_id"); var url = "getStreet.action?districtId="+district.value; createXmlHttpResult(); XMLHTTPResult.open("GET", url,true); XMLHTTPResult.onreadystatechange=backRoll; XMLHTTPResult.send(null); } function backRoll(){ if(XMLHTTPResult.readyState==4){ if(XMLHTTPResult.status==200){ alert(XMLHTTPResult.responseText); } } }
<action name="getStreet" class="com.accp.houserent.action.GetStreetAction"> </action>
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { // TODO Auto-generated method stub String districtId = request.getParameter("districtId"); CommonBiz commonBiz = new CommonBizImpl(); District district =commonBiz.getEntity(District.class,Integer.parseInt(districtId)); response.setContentType("html/text;charset=gbk;"); PrintWriter out = response.getWriter(); String str = null; for (Iterator<Street> ite = district.getStreets().iterator(); ite.hasNext();) { Street temp_street = ite.next(); if (ite.hasNext()) { str+=temp_street.getStreetName()+"-"; }else{ str+=temp_street.getStreetName(); } } out.print(str); return null; }
function backRoll(){ if(XMLHTTPResult.readyState==4){ if(XMLHTTPResult.status==200){ alert(XMLHTTPResult.responseText); } else alert('发生错误:'+XMLHTTPResult.status+'\n'+XMLHTTPResult.responseText)//加这句看看什么问题 } }