利用EXTJS来显示LDAP的树状结构
2009-09-17 00:00:00 来源:WEB开发网用的是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);
%>
更多精彩
赞助商链接