Tree后台实现代码

Tree后台实现代码块(接上文)

代码块

接上文案例2还有代码块没有写出来 现在给你们搞出来:
我从上到下给你们展示出来昂第一个是dao包里面的MenuDao

package com.huangjie.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huangjie.entrty.Menu;
import com.huangjie.util.BaseDao;
import com.huangjie.util.BuildTree;
import com.huangjie.util.PageBean;
import com.huangjie.vo.TreeVo;

public class MenuDao extends BaseDao<Menu>{
	public List<Menu> list(Menu menu,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
		String sql="select * from t_easyui_menu";
		
		return executeQuery(sql,Menu.class, pageBean);
	}
	
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, SQLException, JsonProcessingException {
		MenuDao menu=new MenuDao();
		List<Menu> list = menu.list(null, null);
		//通过工具类完成指定格式的输出
		List<TreeVo<Menu>> nodes=new ArrayList<TreeVo<Menu>>();
		//Permission的格式是不满足easyui的tree组件的展示数据格式的
		//目的:将List<Permission>转化为List<TreeVo<T>>
		//实现:将List<Permission>得到的单个Permission转成TreeVo,将TreeVo加入到nodes
		
		TreeVo treevo=null;
		for (Menu p : list) {
			treevo=new TreeVo<>();
			treevo.setId(p.getMenuid());
			treevo.setText(p.getMenuname());
			treevo.setParentId(p.getParentid());
			/*Map<String, Object> attributes=new HashMap<String,Object>();
			attributes.put("self", p);
			treevo.setAttributes(attributes);*/
			nodes.add(treevo);
		}
		
		TreeVo<Menu> build = BuildTree.build(nodes);
		ObjectMapper om=new ObjectMapper();
		String jsonstr= om.writeValueAsString(build);
		System.out.println(jsonstr);
	}
}

然后是PermissionDao

package com.huangjie.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huangjie.entrty.Permission;
import com.huangjie.util.BaseDao;
import com.huangjie.util.BuildTree;
import com.huangjie.util.PageBean;
import com.huangjie.vo.TreeVo;

public class PermissionDao extends BaseDao<Permission>{
	public List<Permission> list(Permission permission,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
		String sql="select * from t_easyui_permission";
		
		return executeQuery(sql,Permission.class, pageBean);
	}
	
	public static void main(String[] args) throws InstantiationException, IllegalAccessException, SQLException, JsonProcessingException {
		PermissionDao permissionDao=new PermissionDao();
		List<Permission> list = permissionDao.list(null, null);
		//通过工具类完成指定格式的输出
		List<TreeVo<Permission>> nodes=new ArrayList<TreeVo<Permission>>();
		//Permission的格式是不满足easyui的tree组件的展示数据格式的
		//目的:将List<Permission>转化为List<TreeVo<T>>
		//实现:将List<Permission>得到的单个Permission转成TreeVo,将TreeVo加入到nodes
		
		TreeVo treevo=null;
		for (Permission p : list) {
			treevo=new TreeVo<>();
			treevo.setId(p.getId()+"");
			treevo.setText(p.getName());
			treevo.setParentId(p.getPid()+"");
			/*Map<String, Object> attributes=new HashMap<String,Object>();
			attributes.put("self", p);
			treevo.setAttributes(attributes);*/
			nodes.add(treevo);
		}
		
		TreeVo<Permission> build = BuildTree.build(nodes);
		ObjectMapper om=new ObjectMapper();
		String jsonstr= om.writeValueAsString(build);
		System.out.println(jsonstr);
	}
}

dao写完了就是entrty包里面的Menu:

package com.huangjie.entrty;

import java.sql.Date;

public class Menu {
	private String serialNo;
	private String menuid;
	private String menuname;
	private String menuURL;
	private String parentid;
	private String iconcls;
	private String authid;
	private String showflag;
	private String displayno;
	private Date operatime;
	private String operator;
	private String mark;
	private String Extend1;
	private String Extend2;
	private String Extend3;
	private String Extend4;
	private String Extend5;
	public String getSerialNo() {
		return serialNo;
	}
	public void setSerialNo(String serialNo) {
		this.serialNo = serialNo;
	}
	public String getMenuid() {
		return menuid;
	}
	public void setMenuid(String menuid) {
		this.menuid = menuid;
	}
	public String getMenuname() {
		return menuname;
	}
	public void setMenuname(String menuname) {
		this.menuname = menuname;
	}
	public String getMenuURL() {
		return menuURL;
	}
	public void setMenuURL(String menuURL) {
		this.menuURL = menuURL;
	}
	public String getParentid() {
		return parentid;
	}
	public void setParentid(String parentid) {
		this.parentid = parentid;
	}
	public String getIconcls() {
		return iconcls;
	}
	public void setIconcls(String iconcls) {
		this.iconcls = iconcls;
	}
	public String getAuthid() {
		return authid;
	}
	public void setAuthid(String authid) {
		this.authid = authid;
	}
	public String getShowflag() {
		return showflag;
	}
	public void setShowflag(String showflag) {
		this.showflag = showflag;
	}
	public String getDisplayno() {
		return displayno;
	}
	public void setDisplayno(String displayno) {
		this.displayno = displayno;
	}
	public Date getOperatime() {
		return operatime;
	}
	public void setOperatime(Date operatime) {
		this.operatime = operatime;
	}
	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}
	public String getMark() {
		return mark;
	}
	public void setMark(String mark) {
		this.mark = mark;
	}
	public String getExtend1() {
		return Extend1;
	}
	public void setExtend1(String extend1) {
		Extend1 = extend1;
	}
	public String getExtend2() {
		return Extend2;
	}
	public void setExtend2(String extend2) {
		Extend2 = extend2;
	}
	public String getExtend3() {
		return Extend3;
	}
	public void setExtend3(String extend3) {
		Extend3 = extend3;
	}
	public String getExtend4() {
		return Extend4;
	}
	public void setExtend4(String extend4) {
		Extend4 = extend4;
	}
	public String getExtend5() {
		return Extend5;
	}
	public void setExtend5(String extend5) {
		Extend5 = extend5;
	}
	
	public Menu() {
		super();
	}
	public Menu(String serialNo, String menuid, String menuname, String menuURL, String parentid, String iconcls,
			String authid, String showflag, String displayno, Date operatime, String operator, String mark,
			String extend1, String extend2, String extend3, String extend4, String extend5) {
		super();
		this.serialNo = serialNo;
		this.menuid = menuid;
		this.menuname = menuname;
		this.menuURL = menuURL;
		this.parentid = parentid;
		this.iconcls = iconcls;
		this.authid = authid;
		this.showflag = showflag;
		this.displayno = displayno;
		this.operatime = operatime;
		this.operator = operator;
		this.mark = mark;
		Extend1 = extend1;
		Extend2 = extend2;
		Extend3 = extend3;
		Extend4 = extend4;
		Extend5 = extend5;
	}
	@Override
	public String toString() {
		return "Menu [serialNo=" + serialNo + ", menuid=" + menuid + ", menuname=" + menuname + ", menuURL=" + menuURL
				+ ", parentid=" + parentid + ", iconcls=" + iconcls + ", authid=" + authid + ", showflag=" + showflag
				+ ", displayno=" + displayno + ", operatime=" + operatime + ", operator=" + operator + ", mark=" + mark
				+ ", Extend1=" + Extend1 + ", Extend2=" + Extend2 + ", Extend3=" + Extend3 + ", Extend4=" + Extend4
				+ ", Extend5=" + Extend5 + "]";
	}
	
}

然后是Permission:

package com.huangjie.entrty;

public class Permission {
	private long id;
	private String name;
	private String description;
	private String url;
	private long pid;
	private int ismenu;
	private long displayno;
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public long getPid() {
		return pid;
	}
	public void setPid(long pid) {
		this.pid = pid;
	}
	public int getIsmenu() {
		return ismenu;
	}
	public void setIsmenu(int ismenu) {
		this.ismenu = ismenu;
	}
	public long getDisplayno() {
		return displayno;
	}
	public void setDisplayno(long displayno) {
		this.displayno = displayno;
	}
	
	public Permission() {
		super();
	}
	public Permission(long id, String name, String description, String url, long pid, int ismenu, long displayno) {
		this.id = id;
		this.name = name;
		this.description = description;
		this.url = url;
		this.pid = pid;
		this.ismenu = ismenu;
		this.displayno = displayno;
	}
	@Override
	public String toString() {
		return "Permission [id=" + id + ", name=" + name + ", description=" + description + ", url=" + url + ", pid="
				+ pid + ", ismenu=" + ismenu + ", displayno=" + displayno + "]";
	}
	
}

接下来是util包里面的BaseDao

package com.huangjie.util;

import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.huangjie.util.DBAccess;
import com.huangjie.util.PageBean;
import com.huangjie.util.StringUtils;

public class BaseDao<T> {
	public List<T> executeQuery(String sql,Class clz,PageBean pageBean) throws SQLException, InstantiationException, IllegalAccessException{
		List<T> list=new ArrayList<T>();
		Connection con = DBAccess.getConnection();
		PreparedStatement ps=null;
		ResultSet rs=null;
		//查询符合条件的总记录数
		if(pageBean !=null && pageBean.isPagination()) {
			//分页   --列表需求
			String countSql=getCountSql(sql);
			ps=con.prepareStatement(countSql);
			rs=ps.executeQuery();
			if(rs.next()) {
				//赋值总记录数
				pageBean.setTotal(rs.getObject(1).toString());
			}
			//展示想要看到的数据
			String pageSql=getPageSql(sql,pageBean);
			ps=con.prepareStatement(pageSql);
			rs=ps.executeQuery();
		}else {//不分页 --下拉框需求
			ps=con.prepareStatement(sql);
			rs=ps.executeQuery();
		}
		
		while(rs.next()) {
			//list.add(new Book(rs.getInt("bid"), rs.getString("bname"), rs.getFloat("price")));
			
			//反射实例化对象
			T t=(T) clz.newInstance();
			Field[] declaredFields = clz.getDeclaredFields();
			for (Field f : declaredFields) {
				f.setAccessible(true);
				f.set(t, rs.getObject(f.getName()));
			}
		
			list.add(t);
		}
		DBAccess.close(con, ps, rs);
		
		return list;
	}
	
	
	//将普通sql转成查总记录数的sql
	private String getCountSql(String sql) {
		
		return "select count(1) from ("+sql+") t";
	}
	
	//
	private String getPageSql(String sql,PageBean pageBean) {
		// TODO Auto-generated method stub
		return sql+" limit "+pageBean.getStartIndex()+","+pageBean.getRows();
	}
	
	
	//通用增删改
	/**
	 * 
	 * @param sql
	 * @param t            book
	 * @param atters 	   bid,bname,price
	 * @return
	 * @throws SQLException 
	 * @throws SecurityException 
	 * @throws NoSuchFieldException 
	 * @throws IllegalAccessException 
	 * @throws IllegalArgumentException 
	 */
	public int executeUpdate(String sql,T t,String[] atters) throws SQLException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
		Connection con = DBAccess.getConnection();
		PreparedStatement ps=con.prepareStatement(sql);
		
		int loop=1;
		Field f=null;
		//atter={"bid","bname","price"}
		for (String atter : atters) {
			 f = t.getClass().getDeclaredField(atter);
			 f.setAccessible(true);
			 ps.setObject(loop++, f.get(t));
		}
		
		int code=ps.executeUpdate();
		DBAccess.close(con, ps, null);
		return code;
	}

}

然后就是BuildTree

package com.huangjie.util;


import com.huangjie.vo.TreeVo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BuildTree {

	/**
	 * 默认-1为顶级节点
	 * @param nodes
	 * @param <T>
	 * @return
	 */
	public static <T> TreeVo<T> build(List<TreeVo<T>> nodes) {

		if (nodes == null) {
			return null;
		}
		//存放顶级节点(二级节点)容器
		List<TreeVo<T>> topNodes = new ArrayList<TreeVo<T>>();

		for (TreeVo<T> children : nodes) {
			String pid = children.getParentId();
			if (pid == null || "0".equals(pid)) {
				topNodes.add(children);
				//如果是顶级节点,那么结束当前循环,继续下一次的循环
				continue;
			}

			for (TreeVo<T> parent : nodes) {
				String id = parent.getId();
				if (id != null && id.equals(pid)) {
					parent.getChildren().add(children);
					children.setHasParent(true);
					parent.setChildren(true);
					continue;
				}
			}

		}
		//考虑到数据库表中没有顶级节点(一级节点)
		//
		TreeVo<T> root = new TreeVo<T>();
		if (topNodes.size() == 1) {
			//数据库有顶级节点这条数据
			root = topNodes.get(0);
		} else {
			//数据库中没有顶级节点,就进行创建一个
			root.setId("000");
			root.setParentId("-1");
			root.setHasParent(false);
			root.setChildren(true);
			root.setChecked(true);
			root.setChildren(topNodes);
			root.setText("顶级节点");
			Map<String, Object> state = new HashMap<>(16);
			state.put("opened", true);
			root.setState(state);
		}

		return root;
	}

	/**
	 * 指定idparam为顶级节点
	 * @param nodes
	 * @param idParam
	 * @param <T>
	 * @return
	 */
	public static <T> List<TreeVo<T>> buildList(List<TreeVo<T>> nodes, String idParam) {
		if (nodes == null) {
			return null;
		}
		List<TreeVo<T>> topNodes = new ArrayList<TreeVo<T>>();

		for (TreeVo<T> children : nodes) {

			String pid = children.getParentId();
			if (pid == null || idParam.equals(pid)) {
				topNodes.add(children);

				continue;
			}

			for (TreeVo<T> parent : nodes) {
				String id = parent.getId();
				if (id != null && id.equals(pid)) {
					parent.getChildren().add(children);
					children.setHasParent(true);
					parent.setChildren(true);

					continue;
				}
			}

		}
		return topNodes;
	}

}

接着就是DBAccess

package com.huangjie.util;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

/**
 * 提供了一组获得或关闭数据库对象的方法
 * 
 */
public class DBAccess {
	private static String driver;
	private static String url;
	private static String user;
	private static String password;

	static {// 静态块执行一次,加载 驱动一次
		try {
			InputStream is = DBAccess.class
					.getResourceAsStream("config.properties");

			Properties properties = new Properties();
			properties.load(is);

			driver = properties.getProperty("driver");
			url = properties.getProperty("url");
			user = properties.getProperty("user");
			password = properties.getProperty("pwd");

			Class.forName(driver);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

	/**
	 * 获得数据连接对象
	 * 
	 * @return
	 */
	public static Connection getConnection() {
		try {
			Connection conn = DriverManager.getConnection(url, user, password);
			return conn;
		} catch (SQLException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

	public static void close(ResultSet rs) {
		if (null != rs) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
		}
	}

	public static void close(Statement stmt) {
		if (null != stmt) {
			try {
				stmt.close();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
		}
	}

	public static void close(Connection conn) {
		if (null != conn) {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new RuntimeException(e);
			}
		}
	}

	public static void close(Connection conn, Statement stmt, ResultSet rs) {
		close(rs);
		close(stmt);
		close(conn);
	}

	public static boolean isOracle() {
		return "oracle.jdbc.driver.OracleDriver".equals(driver);
	}

	public static boolean isSQLServer() {
		return "com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(driver);
	}
	
	public static boolean isMysql() {
		return "com.mysql.jdbc.Driver".equals(driver);
	}

	public static void main(String[] args) {
		Connection conn = DBAccess.getConnection();
		DBAccess.close(conn);
		System.out.println("isOracle:" + isOracle());
		System.out.println("isSQLServer:" + isSQLServer());
		System.out.println("isMysql:" + isMysql());
		System.out.println("数据库连接(关闭)成功");
	}
}

再然后就是EncodingFiter

package com.huangjie.util;

import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 中文乱码处理
 * 
 */
@WebFilter(filterName="encodingFiter",urlPatterns="*.action")
public class EncodingFiter implements Filter {

	private String encoding = "UTF-8";// 默认字符集

	public EncodingFiter() {
		super();
	}

	public void destroy() {
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse res = (HttpServletResponse) response;

		// 中文处理必须放到 chain.doFilter(request, response)方法前面
		res.setContentType("text/html;charset=" + this.encoding);
		if (req.getMethod().equalsIgnoreCase("post")) {
			req.setCharacterEncoding(this.encoding);
		} else {
			Map map = req.getParameterMap();// 保存所有参数名=参数值(数组)的Map集合
			Set set = map.keySet();// 取出所有参数名
			Iterator it = set.iterator();
			while (it.hasNext()) {
				String name = (String) it.next();
				String[] values = (String[]) map.get(name);// 取出参数值[注:参数值为一个数组]
				for (int i = 0; i < values.length; i++) {
					values[i] = new String(values[i].getBytes("ISO-8859-1"),
							this.encoding);
				}
			}
		}

		chain.doFilter(request, response);
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		String s = filterConfig.getInitParameter("encoding");// 读取web.xml文件中配置的字符集
		if (null != s && !s.trim().equals("")) {
			this.encoding = s.trim();
		}
	}

}

然后PageBean

package com.huangjie.util;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * 分页工具类
 *
 */
public class PageBean {

	private int page = 1;// 页码

	private int rows = 10;// 页大小

	private int total = 0;// 总记录数

	private boolean pagination = true;// 是否分页
	//上一次查询的url
	private String url;
	//上一次查询所携带的查询条件
	private Map<String , String[]> parameterMap=new HashMap<String, String[]>();
	//对pageBean进行初始化
	public void setRequest(HttpServletRequest req) {
		//初始化jsp页面传过来的当前页
		this.setPage(req.getParameter("page"));
		//初始化jsp页面传递过来的页大小
		this.setRows(req.getParameter("rows"));
		//初始化jsp页面传过来是否分页
		this.setPagination(req.getParameter("pagination"));
		//保留上一次的查询请求
		this.setUrl(req.getRequestURI().toString());
		//保留上一次的查询条件
		this.setParameterMap(req.getParameterMap());
	}
	
	//重载
	private void setPage(String page) {
		// TODO Auto-generated method stub
		if(StringUtils.isNotBlank(page))
		this.setPage(Integer.valueOf(page));
	}
	private void setRows(String rows) {
		// TODO Auto-generated method stub
		if(StringUtils.isNotBlank(rows))
		this.setPage(Integer.valueOf(rows));
	}
	private void setPagination(String pagination) {
		// TODO Auto-generated method stub
		//只有填写了false字符串才代表不分页
		this.setPagination(!"false".equals(pagination));
	}
	
	
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Map<String, String[]> getParameterMap() {
		return parameterMap;
	}

	public void setParameterMap(Map<String, String[]> parameterMap) {
		this.parameterMap = parameterMap;
	}

	public PageBean() {
		super();
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public void setTotal(String total) {
		this.total = Integer.parseInt(total);
	}

	public boolean isPagination() {
		return pagination;
	}

	public void setPagination(boolean pagination) {
		this.pagination = pagination;
	}

	/**
	 * 获得起始记录的下标
	 * 
	 * @return
	 */
	public int getStartIndex() {
		return (this.page - 1) * this.rows;
	}

	@Override
	public String toString() {
		return "PageBean [page=" + page + ", rows=" + rows + ", total=" + total + ", pagination=" + pagination + "]";
	}
	
	//上一页
	public int getPrevPage() {
		return this.page>1 ? this.page-1 : this.page;
	}
	//下一页
	public int getNextPage() {
		return this.page<this.getMaxPage() ? this.page+1 :this.page;
	}
	//最大页
	public int getMaxPage() {
		return this.total % this.rows==0 ? this.total / this.rows:(this.total / this.rows)+1;
	}
	
}

再是StringUtils

package com.huangjie.util;

public class StringUtils {
	// 私有的构造方法,保护此类不能在外部实例化
	private StringUtils() {
	}

	/**
	 * 如果字符串等于null或去空格后等于"",则返回true,否则返回false
	 * 
	 * @param s
	 * @return
	 */
	public static boolean isBlank(String s) {
		boolean b = false;
		if (null == s || s.trim().equals("")) {
			b = true;
		}
		return b;
	}
	
	/**
	 * 如果字符串不等于null或去空格后不等于"",则返回true,否则返回false
	 * 
	 * @param s
	 * @return
	 */
	public static boolean isNotBlank(String s) {
		return !isBlank(s);
	}

}

然后是vo包里面的TreeVo

package com.huangjie.vo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class TreeVo<T> {
	/**
	 * 节点ID
	 */
	private String id;
	/**
	 * 显示节点文本
	 */
	private String text;
	/**
	 * 节点状态,open closed
	 */
	private Map<String, Object> state;
	/**
	 * 节点是否被选中 true false
	 */
	private boolean checked = false;
	/**
	 * 节点属性
	 */
	private Map<String, Object> attributes;

	/**
	 * 节点的子节点
	 */
	private List<TreeVo<T>> children = new ArrayList<TreeVo<T>>();

	/**
	 * 父ID
	 */
	private String parentId;
	/**
	 * 是否有父节点
	 */
	private boolean hasParent = false;
	/**
	 * 是否有子节点
	 */
	private boolean hasChildren = false;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Map<String, Object> getState() {
		return state;
	}

	public void setState(Map<String, Object> state) {
		this.state = state;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public List<TreeVo<T>> getChildren() {
		return children;
	}

	public void setChildren(List<TreeVo<T>> children) {
		this.children = children;
	}

	public boolean isHasParent() {
		return hasParent;
	}

	public void setHasParent(boolean isParent) {
		this.hasParent = isParent;
	}

	public boolean isHasChildren() {
		return hasChildren;
	}

	public void setChildren(boolean isChildren) {
		this.hasChildren = isChildren;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public TreeVo(String id, String text, Map<String, Object> state, boolean checked, Map<String, Object> attributes,
                  List<TreeVo<T>> children, boolean isParent, boolean isChildren, String parentID) {
		super();
		this.id = id;
		this.text = text;
		this.state = state;
		this.checked = checked;
		this.attributes = attributes;
		this.children = children;
		this.hasParent = isParent;
		this.hasChildren = isChildren;
		this.parentId = parentID;
	}

	public TreeVo() {
		super();
	}

}

然后就是index配置文件

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<!-- 全局样式 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/themes/default/easyui.css">   
<!-- 定义图标 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/themes/default/easyui.css">   
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/jquery.min.js"></script>   
<!-- 组件库js源码 -->
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>  

<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/index.js"></script>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主界面</title>
</head>
<body class="easyui-layout">
<!-- 头部 -->
	<div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:10px">
	管理系统
	</div>
	<!-- 菜单管理 -->
	<div data-options="region:'west',split:true,title:'West'" style="width:150px;padding:10px;">
		<ul id="tt"></ul>  
	
	
	</div>
	<!-- 内容块 -->
	<div data-options="region:'east',split:true,collapsed:true,title:'East'" style="width:100px;padding:10px;">east region</div>
	<!-- 底部权限 -->
	<div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;">south region</div>
	<div data-options="region:'center',title:'Center'"></div>
</body>
</html>

总结

今天分享的内容就到这里啦 记得要提前导好jar包哦 jar包图片在上一篇博客!!

猜你喜欢

转载自blog.csdn.net/m0_47906344/article/details/106946131