把梅花雪树型结构asp文件改写成了jsp的
可以正常使用 在显示后的html代码和原版asp生成的html代码一样
但是有的时候却不能伸展。。
原版asp代码的从没有出现这个问题~~
请教各位是怎么回事~
====================JSP代码如下=============================
<%@ Language=VBScript codepage=936  %>
<%  Option Explicit %>
<%
  Dim Conn, rs
  Set Conn  = Server.CreateObject("ADODB.Connection")
  Set rs    = Server.CreateObject("ADODB.Recordset")
  Conn.Open  "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& Server.MapPath("./") &"\tree.mdb;"
  rs.open "Select ID, parentId, text, hint, icon, data, url, target, method From treeview order by ID", Conn
%>
<html>
  <head>
    <title>梅花雪中文网 - 网页脚本控件集 MzTreeView10</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="author" content="黄方荣(meizz·梅花雪)://www.meizz.com">
    <script language="JavaScript" src="MzTreeView10.js"></script>
    <link href="http://www.meizz.com/Scripts/Global.css" type="text/css" rel="stylesheet">
    <style>
    A.MzTreeview
    {
      font-size: 9pt;
      padding-left: 3px;
    }
    </style>
  </head>  <body class=frame>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    window.tree = new MzTreeView("tree");    tree.icons["property"] = "property.gif";
    tree.icons["css"] = "collection.gif";
    tree.icons["book"]  = "book.gif";
    tree.iconsExpand["book"] = "bookopen.gif"; //展开时对应的图片
    tree.setIconPath("http://www.meizz.com/Icons/TreeView/"); //可用相对路径
<%
  Dim node
  Dim reg : set reg = new RegExp : reg.global=True : reg.pattern=";"
  Dim id, parentId, text, hint, icon, data, url, target, method
  do while not rs.eof
    '若是树的条目比较多的时候(比如大于1000)而又相对稳定的时候将这些数据生成静态网页来访问
    node = VBCrLf &"    tree.nodes["""& rs("parentId") &"_"& rs("id") &"""] = """
    node = node &"text:"& reg.replace(rs("text"), chr(15)) &";"
    if rs("hint")<>"" then node = node &"hint:"& reg.replace(rs("hint"), chr(15)) &";"
    if rs("icon")<>"" then node = node &"icon:"& rs("icon") &";"
    if rs("data")<>"" then node = node &"data:"& reg.replace(rs("data"), chr(15)) &";"
    if rs("url")<>""  then node = node &"url:"&  reg.replace(rs("url"), chr(15)) &";"
    if rs("target")<>"" then node = node &"target:"& rs("target") &";"
    if rs("method")<>"" then node = node &"method:"& reg.replace(rs("method"), chr(15)) &";"
    response.write node &"""" '生成节点信息
    rs.movenext
  loop
%>
    tree.setURL("Catalog.asp");
    tree.setTarget("MzMain");
    document.write(tree.toString());    //亦可用 obj.innerHTML = tree.toString();
    //-->
    </SCRIPT>
  </body>
</html>
<%
  rs.close : set rs = nothing : Conn.close : set Conn = nothing
%>

解决方案 »

  1.   

    ====================JSP代码如下=============================
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <%@ page import="ch01.Conn"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>论坛</title>
    <script language="JavaScript" src="tree.js"></script>
    <link href="tree.css" type="text/css" rel="stylesheet">
    <style>
        A.MzTreeview
        {
          font-size: 9pt;
          padding-left: 3px;
        }
        </style>
    </head>
    <body class=frame>
    <SCRIPT LANGUAGE="JavaScript">  
    <!--
    window.tree = new MzTreeView("tree");
        tree.icons["property"] = "property.gif";
        tree.icons["css"] = "collection.gif";
        tree.icons["book"]  = "book.gif";
        tree.iconsExpand["book"] = "bookopen.gif"; //展开时对应的图片
        tree.setIconPath("./"); //可用相对路径
    <%
    String node,nodetemp,b;
    char a='"';
        long id,parentId;
    String text,hint,icon,data,url,target,method;
    Conn con = new Conn();
    ResultSet rs;
    rs=con.executeQuery("select * from treeview order by ID");
    while (rs!=null && rs.next()){
     node="tree.nodes["+a+String.valueOf(rs.getLong("parentId"))+"_"+String.valueOf(rs.getLong("Id"))+a+"] = "+a;
     text=rs.getString("text");
     hint=rs.getString("hint");
     icon=rs.getString("icon");
     data=rs.getString("data");
     url=rs.getString("url");
     target=rs.getString("target");
     method=rs.getString("method");
     if (text!=null && text.length()>0)
     {node = node +"text:"+ text+";";
      }
         if (hint!=null && hint.length()>0)
     {node = node +"hint:"+ hint+";";
      }
     if (icon!=null && icon.length()>0) 
     {node = node +"icon:"+icon+";";
      }
     if (data!=null && data.length()>0)
      {node = node +"data:"+ data+";";
      }
     if (url!=null && url.length()>0)
     {node = node +"url:"+ url+";";
      }
       if (target!=null &&target.length()>0)
     {node = node+"target:"+ target+";";
      }
     if (method!=null && method.length()>0)
      {node = node +"method:"+ method+";";
      }
     node=node+a;
     out.println(node);
    }
    rs=null;
    con.closeDB();
    %>
    tree.setURL("Catalog.asp");
    tree.setTarget("MzMain");
    document.write(tree.toString()); 
    //-->
    </SCRIPT></body>
    </html>
      

  2.   

    先把这句改了
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 改
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">好象还少了">"
      

  3.   

    tree.setURL("Catalog.asp");这里面是asp文件吗?
    要看解析的html了
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>论坛</title>
    <script language="JavaScript" src="tree.js"></script>
    <link href="tree.css" type="text/css" rel="stylesheet">
    <style>
        A.MzTreeview
        {
          font-size: 9pt;
          padding-left: 3px;
        }
        </style>
    </head>
    <body class=frame>
    <SCRIPT LANGUAGE="JavaScript">  
    <!--
    window.tree = new MzTreeView("tree");
        tree.icons["property"] = "images/property.gif";
        tree.icons["css"] = "images/collection.gif";
        tree.icons["book"]  = "images/book.gif";
        tree.iconsExpand["book"] = "images/bookopen.gif"; //展开时对应的图片
        tree.setIconPath("./"); //可用相对路径
    tree.nodes["-1_1"] = "text:论坛;url:http://www.meizz.com/Web/Catalog/1.htm;method:alert('欢迎使用梅花雪网页脚本控件集-MzTreeView10');"
    tree.nodes["1_100"] = "text:代码示例;hint:梅花雪编写或者整理的一些代码示例;url:http://www.meizz.com/Web/Catalog/100.htm;"
    tree.nodes["100_101"] = "text:日期时间类;url:http://www.meizz.com/Web/Catalog/101.htm;"
    tree.nodes["1_200"] = "text:梅花雪脚本控件集;hint:梅花雪编写的一些模块化的网页脚插件;url:http://www.meizz.com/Web/Catalog/200.htm;"
    tree.nodes["200_201"] = "text:日历控件;url:http://www.meizz.com/Web/Catalog/201.htm;"
    tree.nodes["200_211"] = "text:TreeView;url:http://www.meizz.com/Web/Catalog/211.htm;"
    tree.nodes["1_300"] = "text:HTML;hint:超文本标示语言(Hypertext Markup Language);url:http://www.meizz.com/Web/Catalog/300.htm;"
    tree.nodes["300_301"] = "text:使用指南;url:http://www.meizz.com/Web/Catalog/301.htm;"
    tree.nodes["300_302"] = "text:HTML Elements;url:http://www.meizz.com/Web/Catalog/302.htm;"
    tree.nodes["1_310"] = "text:CSS;hint:层级式样式(Cascading Style Sheets);url:http://www.meizz.com/Web/Catalog/310.htm;"
    tree.nodes["310_311"] = "text:属性;url:http://www.meizz.com/Web/Catalog/311.htm;"
    tree.nodes["310_312"] = "text:度量单位;url:http://www.meizz.com/Web/Catalog/312.htm;"
    tree.nodes["1_320"] = "text:DHTML;hint:动态网页脚本编程(Dynamic HTML);url:http://www.meizz.com/Web/Catalog/320.htm;"
    tree.nodes["320_321"] = "text:对象;hint:对象(Objects);icon:object;url:http://www.meizz.com/Web/Catalog/321.htm;"
    tree.nodes["320_322"] = "text:属性;hint:属性(Attributes | Properties);icon:property;url:http://www.meizz.com/Web/Catalog/322.htm;"
    tree.nodes["320_323"] = "text:方法;hint:方法(Methods);icon:method;url:http://www.meizz.com/Web/Catalog/323.htm;"
    tree.nodes["320_324"] = "text:事件;hint:事件(Events);icon:event;url:http://www.meizz.com/Web/Catalog/324.htm;"
    tree.nodes["320_325"] = "text:集合;hint:集合(Collections);icon:collection;url:http://www.meizz.com/Web/Catalog/325.htm;"
    tree.nodes["320_326"] = "text:行为;hint:行为(Behaviors);icon:behavior;url:http://www.meizz.com/Web/Catalog/326.htm;"
    tree.nodes["320_327"] = "text:滤镜;url:http://www.meizz.com/Web/Catalog/327.htm;"
    tree.nodes["1_400"] = "text:JavaScript;hint:JavaScript;url:http://www.meizz.com/Web/Catalog/400.htm;"
    tree.nodes["400_401"] = "text:使用指南;url:http://www.meizz.com/Web/Catalog/401.htm;"
    tree.nodes["401_402"] = "text:语言基础;url:http://www.meizz.com/Web/Catalog/402.htm;"
    tree.nodes["401_403"] = "text:高级;url:http://www.meizz.com/Web/Catalog/403.htm;"
    tree.nodes["400_404"] = "text:语言参考;url:http://www.meizz.com/Web/Catalog/404.htm;"
    tree.nodes["404_405"] = "text:函数;url:http://www.meizz.com/Web/Catalog/405.htm;"
    tree.nodes["404_406"] = "text:方法;url:http://www.meizz.com/Web/Catalog/406.htm;"
    tree.nodes["404_407"] = "text:对象;url:http://www.meizz.com/Web/Catalog/407.htm;"
    tree.nodes["404_408"] = "text:运算符;url:http://www.meizz.com/Web/Catalog/408.htm;"
    tree.nodes["404_409"] = "text:属性;url:http://www.meizz.com/Web/Catalog/409.htm;"
    tree.nodes["404_410"] = "text:正则表达式;url:http://www.meizz.com/Web/Catalog/410.htm;"
    tree.nodes["404_411"] = "text:语句;url:http://www.meizz.com/Web/Catalog/411.htm;"
    tree.nodes["404_412"] = "text:综合类;url:http://www.meizz.com/Web/Catalog/412.htm;"
    tree.nodes["1_450"] = "text:VBScript;hint:VBScript;url:http://www.meizz.com/Web/Catalog/450.htm;"
    tree.nodes["450_451"] = "text:使用指南;url:http://www.meizz.com/Web/Catalog/451.htm;"
    tree.nodes["451_452"] = "text:语言基础;url:http://www.meizz.com/Web/Catalog/452.htm;"
    tree.nodes["451_453"] = "text:杂类;url:http://www.meizz.com/Web/Catalog/453.htm;"
    tree.nodes["450_454"] = "text:语言参考;url:http://www.meizz.com/Web/Catalog/454.htm;"
    tree.nodes["454_455"] = "text:常数;url:http://www.meizz.com/Web/Catalog/455.htm;"
    tree.nodes["454_456"] = "text:错误含义;url:http://www.meizz.com/Web/Catalog/456.htm;"
    tree.nodes["454_457"] = "text:关键字;url:http://www.meizz.com/Web/Catalog/457.htm;"
    tree.nodes["454_458"] = "text:函数;url:http://www.meizz.com/Web/Catalog/458.htm;"
    tree.nodes["454_459"] = "text:方法;url:http://www.meizz.com/Web/Catalog/459.htm;"
    tree.nodes["454_460"] = "text:对象与集合;url:http://www.meizz.com/Web/Catalog/460.htm;"
    tree.nodes["454_461"] = "text:运算符;url:http://www.meizz.com/Web/Catalog/461.htm;"
    tree.nodes["454_462"] = "text:属性;url:http://www.meizz.com/Web/Catalog/462.htm;"
    tree.nodes["454_463"] = "text:语句;url:http://www.meizz.com/Web/Catalog/463.htm;"
    tree.nodes["454_464"] = "text:正则表达式;url:http://www.meizz.com/Web/Catalog/464.htm;"tree.setURL("Catalog.asp");
    tree.setTarget("MzMain");
    document.write(tree.toString()); 
    //-->
    </SCRIPT></body>
    </html>
      

  5.   

    编程动力 www.bcexe.com 专业的编程开发类网站,网络编程,软件开发,网站开发,一切尽在这里!