ligerui tree 动态数据加载

public static String createTree(String deptid) {
StringBuffer sb = new StringBuffer(2000);
List> li = null;
if (deptid != null) {
try {
li = getChild(deptid);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (li != null && li.size() > 0) {
sb.append("[");
for (int i = 0; i < li.size(); i++) {
HashMap v = li.get(i);
sb.append(String.format(
"{ 'id':'%1$s','text': '%2$s','isleaf':'%3$s'", v
.get("DEPTID"), v.get("DEPTNAME"),
v.get("ISLEAF").toString()));

                if (v.get("ISLEAF").toString().equals("0")) {
                    sb.append(", children:  ");
                    sb.append(createTree(v.get("DEPTID").toString()));
                }

                if (i != (li.size() - 1))
                    sb.append(" },");
                else
                    sb.append(" }");
            }
            sb.append("]");
        }
    }

    return sb.toString();
}
    public static String initTree(String deptid) {

    StringBuffer sb = new StringBuffer(20000);
    String deptname = "";
    String isleaf = "";
    try {
        List<HashMap<String, Object>> li = getDeptInfo(deptid);

        for (int i = 0; i < li.size(); i++) {

            deptname = li.get(i).get("DEPTNAME").toString();
            isleaf = li.get(i).get("ISLEAF").toString();
        }
        sb.append(String.format("[{ 'id':'%1$s','text': '%2$s','isleaf':'%3$s'", deptid, deptname, isleaf));
        if (isleaf.equals("0")) {
            sb.append(", children:  ");
            sb.append(createTree(deptid));
        }
        sb.append("}]");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return sb.toString();
}
    以上是BEAN
    @RequestMapping(value = "/initTree", method = RequestMethod.POST)
public String initTree(HttpServletRequest request) {
    String deptid = request.getParameter("deptid");
    String tag = request.getParameter("tag");
    List<HashMap<String, Object>> li = null;

    if (deptid != null) {
        {
            li = DeptBean.getParentDept(deptid);
            if (li != null && li.size() > 0) {
                for (int i = 0; i < li.size(); i++) {
                    HashMap<String, Object> v = li.get(i);
                }
            }
            return "";
        }

    }
    return "";
}

以上是CONTROLLER

现在要在页面中获取数据库parent作为根节点 其中一项作为子节点 树状图列出来