您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html;charset=UTF-8"%>
<%
if (request.getProtocol().compareTo("HTTP/1.0") == 0)
response.setHeader("Pragma", "no-cache");
if (request.getProtocol().compareTo("HTTP/1.1") == 0)
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
<head>
<title> ZTREE DEMO - Simple Data</title>
<link rel="stylesheet" href="http://pannijingling.blog.163.com/blog/文件夹路径/demo.css" type="text/css"></link>
<link rel="stylesheet" href="http://pannijingling.blog.163.com/blog/文件夹路径/zTreeStyle.css" type="text/css"></link>
<script type="text/javascript" src="http://pannijingling.blog.163.com/blog/文件夹路径/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://pannijingling.blog.163.com/blog/文件夹路径/jquery.ztree.core-3.1.js"></script>
<SCRIPT type="text/javascript">
<!--
var setting = {
data: {
simpleData: {
enable: true
}
}
};
var zNodes =[
//这里只需要将后台传出的list使用jstl循环输出
<c:forEach items="${treelist}" var="tree" varStatus="vs">
${tree}
</c:forEach>
];
$(document).ready(function(){
//“treeDemo”是ul的ID
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
//-->
</SCRIPT>
</head>
<body">
<div>
<ul id="treeDemo" class="ztree"></ul>
</div>
</body>
</HTML>
public List getTreelist(){
//设定树菜单的根
String ztree = "{ id:00, pId:0, name:'要显示的根名,也可以从数据库取出', click:\"parent.setIframesrc()\" , open:true },";
List ztreeList = new ArrayList();
//从数据库获取所有菜单的信息
List menuList = this.getMenuList();
if(Collections.isNotEmpty(menuList)){
ztreeList.add(ztree);
for (int i = 0; i < menuList.size(); i++) {
Menu menu = (Menu) menuList.get(i);
//按照一定的格式拼接字符串,最后返回到jsp页面
ztree = "{ id:"+menu.getMenuid()+", pId:"+menu.getParentid()+", name:\""+menu.getMenuname()+"\"," +
"click:\"parent.setIframesrc('"+menu.getMenuid()+"')\"},";
if (i+1 == menuList.size()) {
ztree = ztree.substring(0, ztree.lastIndexOf(","));
}
ztreeList.add(ztree);
}
}
return ztreeList;
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。