jquery ajax后台向前台传list 前台用jquery $.each遍历list
下边是两种前台接收并遍历list
下边是后台接收并遍历listHttpServletResponse res = ServletActionContext.getResponse();res.reset();res.setContentType("text/html;charset=utf-8");PrintWriter pw = res.getWriter();xxx.setId(1);xxx.setName("黑色头发");list.add(xxx);xxx.setId(2);xxx.setName("紫色头发");list.add(xxx);String json = JSONArray.fromObject(list).toString(); pw.print(json);pw.flush();pw.close();
黑色头发:http://heisetoufa.iteye.com/