可以先放到hidden域中,然后通过jquery先获取hidden域的值,然后用$("selectid").val("hidden域的值");
假设select的ID为 aselect ,后台获取的值为 test ,赋值语句为:
$("#aselect").val('test');
java code:
List
list.add("北京");
list.add("上海");
....
JSONArray jsonObject = JSONArray.fromObject(list);//导入json包
String jsonString = jsonObject.toString();
HttpServletResponse response = ServletActionContext.getResponse();
response .setCharacterEncoding("UTF-8");
PrintWriter pw =response .getWriter();
pw.write(jsonString);
pw.flush();
pw.close();
页面:
以上代码纯手写的,未测试!