可以用 xml, xslt 做

解决方案 »

  1.   

    建表1:
    目录id  部门名称
    0       系统目录
    001     生产部门
    建表2:
    目录id  级数1 级数2 级数3 级数4 级数5 级数6
    0       1      0    0     0     0     0
    001     0      1    0     0     0     0按照级数把它拼装成一个树形的list或者树组,有些遗忘,有问题再提。这种结构确实有些复杂,就算实现了也很难处理的。
      

  2.   

    这样吧,可否不使用递归也可以实现以上目录树的结构!!!我的代码是
    <%!
    String sId;
    String sName;
    String sTemp;
    ResultSet rset=null;
    int iCount=0;
    int iLen = 0;
    int iLength = 3;
    int iLens=3;
    %>
    <div>
    <span><input type=checkbox>企业</span>
    <UL id=root>
    <%
      rset=conn.executequery("select * from tree  order by id");
    //主目录信息
      while (rset.next())
      {
           sId = rset.getString("id");
           iLen = sId.length();
           sName=rset.getString("name");
           ResultSet rs = conn.executequery("select count(*) as icount from tree where id like: '"+sId+"%'");
          if(rs.next())  iCount = rs.getInt("icount");//得到是否有下级目录
           if(iCount==1)
            {
    %>
                <LI><span><input type=checkbox value=<%=sId%>> <%=sName%></span>
    <%
            }
          if((iCount>1)&&((iLength-iLen==0)||(iLen % iLength==0)))
           {
    %>
             <LI><span><input type=checkbox value=<%=sId%>> <%=sName%></span>
             <UL>
    <%
           }
           if(iLen-iLens<0)
           {
    %>
             </UL><%
           }   iLens = iLen;
      }
    %>
    </UL>
    </div>
    但是在没有子目录情况下就会出错!!如何更改?或者有更好的解决办法