数据结构:
root_id | son_id | uid | title  | content | createdate | type | attaches |
+---------+--------+-----+--------+---------+------------+------+----------+
|       0 |      1 |   0 | 欧洲   | aaa     | 1356969600 |    0 |          |
|       1 |      2 |   0 | 法国   | aaa1    | 1356969600 |    0 |          |
|       1 |      3 |   0 | 荷兰   | aaa2    | 1356969600 |    0 |          |
|       0 |      4 |   0 | 美洲   | bbb     | 1356969600 |    0 |          |
|       4 |      5 |   0 | 美国   | bbb1    | 1356969600 |    0 |          |
|       4 |      6 |   0 | 加拿大 | bbb2    | 1356969600 |    0 |          |
|       4 |      7 |   0 | 墨西哥 | bb3     | 1356969600 |    0 |          |
|       1 |      8 |   0 | 英国   | aaa3    | 1356969600 |    0 |          |
|      11 |      9 |   0 | 韩国   | ccc1    | 1356969600 |    0 |          |
|      11 |     10 |   0 | 中国   | ccc2    | 1356969600 |    0 |          |
|       0 |     11 |   0 | 亚洲   | ccc     | 1356969600 |    0 |          |
|      10 |     12 |   0 | 福建省 | c2c01   | 1356969600 |    0 |          |
|      10 |     13 |   0 | 广东省 | c2c11   | 1356969600 |    0 |          |
|      10 |     14 |   0 | 江苏省 | c2c22   | 1356969600 |    0 |          |
|      14 |     15 |   0 | 昆山市 | c2c2c01 | 1356969600 |    0 |          |
|      14 |     16 |   0 | 苏州市 | c2c2c11 | 1356969600 |    0 |          |

解决方案 »

  1.   

    ORACLE有层次查询,可以定义起点,并且可以规定父节点和子节点的关系,具体忘记了,查查看
      

  2.   

    我jsp里引用了 jquery实现的树形结构
    地址:http://www.56gee.com/Detail/2012/04/11/8AEB74E423/
      

  3.   

    先找个前端树控件  如ztree   jquery treeview  等之前用operamasks写过东西推荐下http://ui.operamasks.org/website/demos.html#omTree#0
    他有一种简单数据类型   你只需要直接吧数据查询出来  他自动回帮你展现成树形结果
      

  4.   

    ztree  可以的  好用快速  查查资料 
      

  5.   

    http://blog.csdn.net/houpengfei111/article/details/8003717
      

  6.   

    页面写个方法 递归一下 类似oracle的start with connect by
    递归查找
      

  7.   

    <%!
    String str = "";
    boolean login = false;
    private void tree(Connection conn, int id, int level) {
    Statement stmt = null;
    ResultSet rs = null;
    String preStr = "";
    for(int i=0; i<level; i++) {
    preStr += "----";
    }
    try {
    stmt = conn.createStatement();
    String sql = "select * from article where pid = " + id;
    rs = stmt.executeQuery(sql);
    String strLogin = "";

    while(rs.next()) {
    if(login) {
    strLogin = "<td><a href='Delete.jsp?id=" + rs.getInt("id") + "&pid=" + rs.getInt("pid") + "'>删除</a>";
    }
    str += "<tr><td>" + rs.getInt("id") + "</td><td>" +
           preStr + "<a href='ShowArticleDetail.jsp?id=" + rs.getInt("id") + "'>" + 
           rs.getString("title") + "</a></td>" +
           strLogin +
           "</td></tr>";
    if(rs.getInt("isleaf") != 0) {
    tree(conn, rs.getInt("id"), level+1);
    }
    }
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    try {
    if(rs != null) {
    rs.close();
    rs = null;
    }
    if(stmt != null) {
    stmt.close();
    stmt = null;
    }
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }
    %>
    引用马士兵老师的BBS 一段递归展现帖子的 jsp页面方法