public class City { private String cValue; private String cName; } js 代码 做一个省市级联效果 sendAjaxRequest();参见ajax学习笔记 <mce:script type="text/javascript"><!-- //加载省份 function changeMe(){ var province = document.getElementById("province"); sendAjaxRequest("cityChangeServlet.do","province="+province.value,myback); }; function myback() { if (xhr.readyState == 4) { // 响应已完成 if (xhr.status == 200) {// 成功处理 var city = document.getElementById("city"); var city2 = JSON.parse(xhr.responseText); for(var i in city2) { for(var j in city2[i]) { opt = new Option(city2[i][j].CName,city2[i][j].CValue); city.appendChild(opt); } } } } } // --></mce:script> <body> <select id="province" name="province" onchange="getCity()"> <option>--请选择省--</option> <option selected="selected" id="021" value="021">上海</option> <option id="010" value="010">北京</option> </select> <select id="city" name="city"> <option>--请选择市--</option> </select> </body> servlet 代码 @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String province = req.getParameter("province"); int provinceid = Integer.parseInt(province); City city = new City("bj","北京"); City city2 = new City("tx","通县"); City city3 = new City("cp","昌平"); List listCity = new ArrayList(); listCity.add(city); listCity.add(city2); listCity.add(city3); City city4 = new City("sh","上海"); City city5 = new City("shx","上海县"); City city6 = new City("jd","嘉定"); List listCity2 = new ArrayList(); listCity.add(city4); listCity.add(city5); listCity.add(city6); JSONArray ja = new JSONArray(); JSONArray jash = new JSONArray(); ja.add(listCity); jash.add(listCity2); PrintWriter out = resp.getWriter(); if(provinceid==10){ out.print(ja); }else{ out.print(jash); } out.flush(); }