Service层: @Service public class ItemCatServiceImpl implements ItemCatService { @Autowired private TbItemCatMapper itemCatMapper; @Override public List getItemCatList(long parentId) { // 根据parentId查询分类列表 TbItemCatExample example = new TbItemCatExample(); //设置查询条件 Criteria criteria = example.createCriteria(); criteria.andParentIdEqualTo(parentId); //执行查询 List list = itemCatMapper.selectByExample(example); //转换成EasyUITreeNode列表 List resultList = new ArrayList<>(); for (TbItemCat tbItemCat : list) { //创建一个节点对象 EasyUITreeNode node = new EasyUITreeNode(); node.setId(tbItemCat.getId()); node.setText(tbItemCat.getName()); node.setState(tbItemCat.getIsParent()?"closed":"open"); //添加到列表中 resultList.add(node); } return resultList; } } Controller层: @Controller @RequestMapping("/item/cat") public class ItemCatController { @Autowired private ItemCatService itemCatService; @RequestMapping("/list") @ResponseBody public List getItemCatList(@RequestParam(value="id", defaultValue="0")Long parentId) { List list = itemCatService.getItemCatList(parentId); return list; } } JS:显示异步tree: initItemCat : function(data){ $(".selectItemCat").each(function(i,e){ var _ele = $(e); if(data && data.cid){ _ele.after(""+data.cid+""); }else{ _ele.after(""); } _ele.unbind('click').click(function(){ $("
").css({padding:"5px"}).html("
    ") .window({ width:'500', height:"450", modal:true, closed:true, iconCls:'icon-save', title:'选择类目', onOpen : function(){ var _win = this; $("ul",_win).tree({ url:'/item/cat/list', animate:true, onClick : function(node){ if($(this).tree("isLeaf",node.target)){ // 填写到cid中 _ele.parent().find("[name=cid]").val(node.id); _ele.next().text(node.text).attr("cid",node.id); $(_win).window('close'); if(data && data.fun){ data.fun.call(this,node); } } } }); }, onClose : function(){ $(this).window("destroy"); } }).window('open'); }); }); }, jsp: 选择类目