WEB开发网
开发学院软件开发Java 利用EXTJS来显示LDAP的树状结构 阅读

利用EXTJS来显示LDAP的树状结构

 2009-09-17 00:00:00 来源:WEB开发网   
核心提示: 用的是jsp来创建jsonTree.jsp代码<%@ page language="java" import="java.util.*" import="ldap.connect.*" import="org.spr

用的是jsp来创建json

Tree.jsp代码

<%@ page language="java"
    import="java.util.*"
    import="ldap.connect.*"
    import="org.springframework.context.ApplicationContext"
    import="org.springframework.context.support.ClassPathXmlApplicationContext"
    pageEncoding="utf-8"%>
<%
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    
    String node = request.getParameter("node");
    //System.out.println(node);
    
    ApplicationContext ac =
            new ClassPathXmlApplicationContext(
                    "applicationContext.xml");
        LdapConnect ldapConnect = (LdapConnect)ac.getBean("userDao");
        
    String json = "";
    String id = "";
    List list = ldapConnect.getList(node);
    
    if(list.size()==0)    
        response.getWriter().print(json);
        
    json += "[";
    for(int i=0;i<list.size();i++){
        //System.out.println(list.get(i));
        if(node.length()>1 || !" ".equals(node)){
            id = list.get(i)+","+node;
        }
        else {
            id = (String)list.get(i);
        }
        //System.out.println(id);
        json += "{id:'"+id+"',text:'"+list.get(i)+"',qtip:'"+id+"'}";
        if(i+1 < list.size())
            json += ",";
    }
    json += "]";    
    response.getWriter().print(json);
    
%>

Tags:利用 EXTJS 显示

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接