这个题目怎么做啊,做不来了 存储城市信息,选择某个城市,相应的城市的区号、邮编、城市等级也显示出来。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 LZ:思路应该是当你选择城市下拉框,onchange改变的时候,调用一个ajax请求,查询出这个城市对应的bean信息,之后返回json,在jsp页面在给区号,邮编赋值! $.ajax({ url : "自己请求的action,或者servlet地址", data : "cityID=" + cityID, type : "post", dataType : "json", success : function(date) { document.getElementById("postCode").value=data.postCode; document.getElementById("cityQuHao").value=data.cityQuHao; } });action 或者servlet代码 JSONObject json = new JSONObject(); json.put("postCode","10010"); json.put("cityQuHao","001001"); super.response().setCharacterEncoding("UTF-8"); super.response().setContentType("text/javascript"); PrintWriter printWrite=null; try { printWrite = super.response().getWriter(); printWrite.write(json.toString()); } catch (IOException e) { logger.error(e, e); }finally{ if(printWrite!=null){ printWrite.close(); } } 这个你前台是jsp吧,这个的用到ajax,楼主你试试吧。主要是思路先通了! 求助 用JAVA写出了一个杨辉三角。。可是怎么打印出来的只有一列呢,求指教 一个关于for循环的问题? 请教连续四个JComboBox()的问题 谢谢 求教:正则表达式如何匹配法文字母 一个简单的程序。 大家帮忙看看,Socket soc=new Socket(134.168.6.185,12345),为什么老是报错。 请问谁知道哪儿有免费的jdbc连mssqlserver的驱动程序? 实时获取进度 import是指什么 java图形界面编程 关于运算符的问题,帮帮看。。。。
$.ajax({
url : "自己请求的action,或者servlet地址",
data : "cityID=" + cityID,
type : "post",
dataType : "json",
success : function(date) {
document.getElementById("postCode").value=data.postCode;
document.getElementById("cityQuHao").value=data.cityQuHao;
}
});
action 或者servlet代码
JSONObject json = new JSONObject();
json.put("postCode","10010");
json.put("cityQuHao","001001");
super.response().setCharacterEncoding("UTF-8");
super.response().setContentType("text/javascript");
PrintWriter printWrite=null;
try {
printWrite = super.response().getWriter();
printWrite.write(json.toString());
} catch (IOException e) {
logger.error(e, e);
}finally{
if(printWrite!=null){
printWrite.close();
}
}