后台查询到的List分装成combotree所需的数据源

数据展示

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");
    }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值