简体   繁体   中英

Display tree structure on a jsp using Recursion and JSTL

I would like to implement a tree structure in my JSP baised web-application using recursion and JSTL.The values of tree is populated from database using java(using some list or map..).I know this question may be asked by some peoples.but i didn't get any idea from those resources.Please help me..

Here is my Table Structure for company table.

      Column                Type

      Company_id            int

      Company_parent_id     int 

      Company_name         varchar(50)

Class Company

     public Class Company{
            private int companyId;
            private int companyParantId;
            private String companyName;

     //getters&setters
     }

Sample tree structure that i watnt to implement.

    1
      1.1
      1.2
          1.2.1
                1.2.1.1

   2
      2.1
   3
      3.1
          3.1.1
      .....
   n 
      n.1
     ....

My question is How can i implement Recursion in jsp with the help of JSTL?.

Thanks,

You may want to look at Displaying tree on JSP page post.

There is good discussion about how to achieve it manually (using jsp recursion) and also a good list of third-party utilities that can easily do it for you.

I have recently implemented a very similar structure. Simply by building the list and recording the parent id, it is possible using Jquery and the jquery.treeTable.js plugin to display this hierarchy as a tree with expandable/collapsible nodes.

Not exactly what you asked, but as you know coding in JSP is frowned upon, this is rather a good way I feel.

See http://ludo.cubicphuse.nl/jquery-treetable/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM