<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>异步加载</title> <link rel="stylesheet"href="${pageContext.request.contextPath}/zTree_v3-master/css/demo.css?1.1.11"> <link rel="stylesheet"href="${pageContext.request.contextPath}/zTree_v3-master/css/zTreeStyle/zTreeStyle.css?1.1.11"> <script type="text/javascript"src="${pageContext.request.contextPath}/jquery-2.1.1.min.js?1.1.11"></script> <script type="text/javascript"src="${pageContext.request.contextPath}/zTree_v3-master/js/jquery.ztree.core.min.js?1.1.11"></script> <script type="text/javascript">var setting = { async : { enable : true, url : "${pageContext.request.contextPath}/ztreeAction!getMenusById.jhtml", autoParam : [ "id" ],//dataFilter : filter }, data : { key : { url : "xUrl"}, simpleData : { enable : true, pIdKey : "pid"} }, }; $(document).ready(function() { $.fn.zTree.init($("#treeDemo"), setting); });</script> </head> <body> <div class="ztree"style="width: 20%; height: 500px; padding-top: 10px; float: left; border: 1px solid #FF0000;"> <ul id="treeDemo"></ul> </div> </body> </html>
上面呢,是jsp頁面的程式碼,因為是純外掛程式測試,可以直接複製過去使用的,
action层代码,可以直接复制使用
public void getMenusById(){ List<Ztree> list=null;try { list=ztreeService.getMenusById(ztree); } catch (Exception e) { e.printStackTrace(); }super.writeJson(list); }
List<Ztree> getMenusById(Ztree ztree) Exception; //接口
"ztreeService" ZtreeServiceImpl List queryList(Ztree ztree) =" from Ztree where 1=1 "<String, Object> params = HashMap<String, Object>(ztree.getId()!=+=" and id = :id ""id" List<Ztree> getMenusById(Ztree ztree) =" from Ztree where 1=1 "<String,Object> params= HashMap<String,Object>(ztree.getId()==||ztree.getId().equals(""+=" and pid is null "+= " and pid = :id ""id"<Ztree> queryZtree =<Ztree> list= ArrayList<Ztree>"true" queryBoolean(Ztree ztree) flag== " from Ztree where pid = :id "<String,Object> params= HashMap<String,Object>"id"<Ztree> queryZtree =(queryZtree!=&&queryZtree.size()>0=
dao層就不用寫了吧,只是一個查詢,下面我把ztree的表格欄位附上
希望可以幫到大家,這就是我再學習ztree插件時的測試程式碼,ssh框架註解版,在其他框架裡還沒試過,但是了解了使用方法,應該都沒問題,我相信你們都比我強的多。不是大神,只是分享一下。大神勿噴~~~~~~~~~~
#以上是zTree樹形外掛程式使用--非同步載入方法介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!