js接受java后台元素为键值对的list的json数据
后台传递: public void f(HttpServletResponse response) { // ..... // AList = ['11', '22', '33']; // BList = [{'11', 11}, {'22', 22}, {'33', 33}]; //将要传递的数据包装成一个个的list Map map = new HashMap(); map.put("AList", AList); map.put("BList", Blist); //将map转成一个json对象 JSONObject frontSend = JSONObject.parseObject(JSON.toJSONString(map)); //设置字体 response.setCharacterEncoding("UTF-8"); try { response.getWriter().println(frontSend ); } catch (IOException e) { e.printStackTrace(); } } 前台接受: // ... success : function (result) { var resultJson = eval('(' + result+ ')'); var AList = resultJson.AList; var BList =