ajaxdispose.java

来自「用selevet+ajax动态生成ajax树!」· Java 代码 · 共 50 行

JAVA
50
字号
package util;
import java.sql.*;
/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class AjaxDispose {

	
	public String getChildNodes(String id)
	{
		StringBuffer childs = new StringBuffer("<?xml version=\"1.0\" encoding=\"GBK\"?>");
		try	{
			
			Conn conn = new Conn();
			  Connection con = conn.getConnection();
			  Statement stateMent = con.createStatement();
			  ResultSet rs = stateMent.executeQuery("select * from dictionary where parentItem = " + id);
			  String elementText = "";
			  String elementValue = "";
			  String elementCode = "";
			  String elementIsParent="";
			  String elementSrc="";
			  childs.append("<AllTrees>");
			  while(rs.next())
			  {
			  	elementText = rs.getString("name");
			  	elementValue = rs.getString("id");
			  	elementCode = rs.getString("code");
			  	elementIsParent = rs.getString("isparent");
			  	elementSrc = rs.getString("src");
			  	//childs.append("<City><MyCity><a href =\"javascript:requestSend("+elementValue+")\">"+elementText+"</a></MyCity></City>");
			  	childs.append("<Trees><Tree id=\""+elementValue+"\" code=\""+elementCode+"\">"+elementText+"</Tree><IsParent>"+elementIsParent+"</IsParent><Src>"+elementSrc+"</Src></Trees>");
			  }
			  childs.append("</AllTrees>");
				conn.disConnection();
			   	stateMent.close();
			    rs.close();
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
		
		
		return childs.toString();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?