欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

jquery zTree异步加载简单实例讲解_jquery

程序员文章站 2022-04-05 19:12:23
...
本文实例讲解了jquery zTree异步加载,分享给大家供大家参考,具体内容如下

web.xml中Servlet配置如下:

 
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  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异步加载实例分享给大家,希望对大家学习异步加载技术有所帮助。