tree树形
/**
* tree
* @param menuBeans
* @param pid
* @return
*/
public JSON makeTree(List<MenuBean> menuBeans,Integer pid){
Map<String, Object> jsonMap;
List<Map<String, Object>> lmjson = new ArrayList<Map<String,Object>>();
for(MenuBean bean: menuBeans){
if(pid==bean.getMenuParentId()||pid.equals(bean.getMenuParentId())){
jsonMap = new HashMap<String, Object>();
jsonMap.put("id", bean.getMenuParentId());
jsonMap.put("text", bean.getText());
if(bean.getLeaf()==0){
if(bean.getMenuParentId()==0){
jsonMap.put("state","open");
}else{
jsonMap.put("state","closed");
}
jsonMap.put("children",makeTree(menuBeans,bean.getId()));
}else{
String url=bean.getMenuUrl();
if(url.contains("www")||url.contains("http")){
}else{
String urlR [] = url.split("/");
url=urlR[0]+"/"+urlR[1]+"/easyui"+urlR[2];
}
jsonMap.put("url",url);
}
lmjson.add(jsonMap);
}
}
return JSONArray.fromObject(lmjson);
}