日期:2014-05-17  浏览次数:20743 次

动态dtree不显示,麻烦帮我看看,愁死了!!!!!!!
这是生成xml的servlet:
package com.handler;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.DaoTest;
import com.dao.Nodes;
public class NodesPrint extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
  doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("调用servlet生成xml文件");
  request.setCharacterEncoding("utf-8");
  response.setContentType("text/xml;charset=utf-8");
  //response.setHeader("ContentType","text/xml");
  PrintWriter out = response.getWriter();
  DaoTest test = new DaoTest();
  ArrayList list= test.getNodeInfo();
   
  //System.out.println("#"+list.size()+"#");
  if(list!=null&&list.size()>0){
  //System.out.println(list.size()+"是长度");
  out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  out.println("<nodes>");
  for(int i=0;i<list.size();i++){
 
  Nodes node = (Nodes) list.get(i);
  //out.println("<node nodeId='1' parentId='1' hrefAddress='www.baidu.com'>节点</node>");
 
  out.println("<node nodeId='"+node.getClassid()+"'parentId='"+node.getParentid()+"'hrefAddress='"+node.getFormid()+"'>"+node.getClassname()+"</node>");
  }
  out.println("</nodes>");
  }
}
}
这是显示的jsp
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>树形结构</title>
<script type="text/javascript" src="dtree.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<link rel="stylesheet" href="dtree.css" type="text/css"></link>
<script type="text/javascript">
//alert(nodeId+"/"+parentId+"/"+nodeName+"/"+hrefAddress);
tree = new dTree('tree');//创建一个对象.
tree.add(0,-1,"这是根节点");
$.ajax({ 
url:'NodesPrint', 
type:'post', //数据发送方式 
dataType:'xml', //接受数据格式 
error:function(xml){
alert('Error loading XML document'+xml);  
},
async: false ,
success: function(xml){
//alert(xml);
//alert("ok");