当前位置:Gxlcms > JavaScript > jqueryzTree异步加载简单实例讲解_jquery

jqueryzTree异步加载简单实例讲解_jquery

时间:2021-07-01 10:21:17 帮助过:7人阅读

本文实例讲解了jquery zTree异步加载,分享给大家供大家参考,具体内容如下

web.xml中Servlet配置如下:

<?xml version="1.0" encoding="UTF-8"?> 
 
   
   
   
    getDataServlet;  
    testTree.TestTree;  
   
   
   
  getDataServlet;  
  /getData;  
   
 
 

JSP页面:

 
 
 
   ZTREE DEMO - Simple Data 
   
   
   
   
  
 
 

最简单的树 -- 简单 JSON 数据

[ 文件路径: core/simpleData.html ]

    Action代码:

    public class TestTree extends HttpServlet { 
     
      @Override 
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    //   System.out.println("--------doGet--------"); 
        this.doPost(request, response); 
      } 
     
      @Override 
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    //   System.out.println("--------doPost--------"); 
        String id = request.getParameter("id"); 
        String name = request.getParameter("name"); 
        String level = request.getParameter("level"); 
        String otherParam = request.getParameter("otherParam"); 
        System.out.println(id + "|" + name + "|" + level + "|" + otherParam); 
         
        JSONObject json = new JSONObject(); 
        List> list = new ArrayList>(); 
         
        for(int i = 0; i < 5; i++){ 
          HashMap hm = new HashMap();  //最外层,父节点       
          hm.put("id", id + i);//id属性 ,数据传递  
          hm.put("name", id + i); //name属性,显示节点名称  
          hm.put("pId", id); 
           
          list.add(hm); 
        } 
         
        JSONArray arr = new JSONArray(list); 
        json.put("success", true); 
        json.put("arr", arr); 
         
        System.out.println("--------json------" + json.toString()); 
        response.getWriter().write(arr.toString()); 
    //   response.getWriter().write(json.toString()); 
    //   response.getWriter().write("[{pId:'2',name:'20',id:'20'}]"); 
      } 
     
    } 

    以上就是jquery zTree异步加载实例分享给大家,希望对大家学习异步加载技术有所帮助。

    人气教程排行