一、@H_404_6@@H_404_6@假设要转换的list为:unitDetalJson@H_404_6@
@H_404_6@ @H_404_6@1,在后台代码中将list变成json类型:@H_404_6@
JSONArray.fromObject(unitDetailList).toString()@H_404_6@
需要中eval转换
@H_404_6@$.each(eval(data.unitDetalJson),function (n,value) {
});
二、将list在后台迭代放到json里面,假设list为baseProjectList@H_404_6@
getRequest().setCharacterEncoding("utf-8");
getResponse().setCharacterEncoding("utf-8");
JSONArray objs=new JSONArray();
for(int i=0;i<baseProjectList.size;i++){
JSONObject obj=new JSONObject();@H_404_6@
obj.put("text",list.get(i).get(xx));@H_404_6@
objs.add(obj);@H_404_6@
}
@H_404_6@getResponse().getWriter().println(objs.toString());
2,jsp代码
ajax({
data.xxx
})