1 前端页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>左侧树形导航栏
2.后台代码
@Controller@SessionAttributes("userT")public class Test { @RequestMapping("TestZTree") public @ResponseBody String TestZTree() { Tree s1 = new Tree(1,0,"test1",true); Tree s2 = new Tree(2,0,"test2",true); Tree s3 = new Tree(3,0,"test3",true); Tree s4 = new Tree(4,0,"test4",true); Tree s5 = new Tree(5,0,"test5",true); Tree s6 = new Tree(6,0,"test6",true); Tree s7 = new Tree(7,0,"test7",true); Tree s8 = new Tree(8,0,"test8",true); Tree s9 = new Tree(9,0,"test9",true); Tree s10 = new Tree(10,0,"test10",true); Tree s11 = new Tree(11,0,"test11",true); List效果图:lstTree = new ArrayList (); lstTree.add(s1); lstTree.add(s2); lstTree.add(s3); lstTree.add(s4); lstTree.add(s5); lstTree.add(s6); lstTree.add(s7); lstTree.add(s8); lstTree.add(s9); lstTree.add(s10); lstTree.add(s11); return makeTree(lstTree); } public static String makeTree(List roles){ //Check Roles is null StringBuffer sb = new StringBuffer(); Tree r = null; sb.append("["); for(int i=0;i