![数据展示](https://img-blog.csdn.net/20161011153317550)
package com.hopechart.configrec.entity;
public class LineTree {
private String key;
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
public void allLine(HttpServletRequest request,HttpServletResponse response) throws Exception {
String str = "";
List<String>allLines=configRecService.queryConfigRecAllLine();
List<LineTree> tree = new ArrayList<LineTree>();
for (int i = 0; i < allLines.size(); i++) {
LineTree combo = new LineTree();
combo.setKey("0"+i);
combo.setValue(allLines.get(i));
tree.add(combo);
}
List<HashMap<String, Object>> roots = new ArrayList<HashMap<String,Object>>();
HashMap<String, Object> root = new HashMap<String, Object>();
root.put("id", "");
root.put("text", "全部");
root.put("iconCls", "");
HashMap<String, Object> group1 = new HashMap<String, Object>();
group1.put("id", "0");
group1.put("text", "车辆档案设置");
group1.put("iconCls", "");
List<HashMap<String, Object>> list = new ArrayList<HashMap<String,Object>>();
for (LineTree data : tree) {
HashMap<String, Object> type = new HashMap<String, Object>();
type.put("id", data.getKey());
type.put("text", data.getValue());
type.put("iconCls", "");
list.add(type);
}
group1.put("children", list);
List<HashMap<String, Object>> group = new ArrayList<HashMap<String, Object>>();
group.add(group1);
root.put("children", group);
roots.add(root);
str = JSONArray.fromObject(roots).toString();
WebUtils.write(response, str, "html");
}