bean
package com.bawei.bean;
import lombok.Data;
/**
* Created by zhongenguang on 2017/8/25.
*/
@Data
public class Ztreea {
private Integer id;
private String name;
private Integer pid;
private String url;
}
action
@ResponseBody
@RequestMapping(value = "shu.do")//目录
public List<Ztreea> select(){
return serviceImpl.select();
}
@RequestMapping("index")
public String index(){return "jso";}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="zTree/js/jquery-1.4.4.min.js"></script>
<script src="zTree/js/jquery.ztree.core.js"></script>
<link rel="stylesheet" href="zTree/zTreeStyle/zTreeStyle.css">
</head>
<script type="text/javascript">
function myFunction() {
var setting = {
data : {
simpleData : {
enable : true,
idKey : "id",
pIdKey : "pid",
url:"url",
rootPId : ""
}
}
}; $(function() {
$.ajax({
type : "POST",
url : "shu.do",
success : function(data) {
// alert(data);
$.fn.zTree.init($("#treeDemo"), setting, data);
}
});
});}
</script>
<body onpageshow="myFunction()">
<div>
<h1>1</h1>
<ul id="treeDemo" class="ztree"></ul>
</div>
</body>
</html>