I have two tables call maintab,subtab for generate menubar.
maintab has
maitabId ,main_tab_name
subtab has:
sub_tb_ID ,main_tb_id,subtab_name ,Url
I want to get two list containig list1=maintabid & maintabname
list2=subtabname,maintabID & url
I want to return the two list using spring mvc. And retrieve in jsp page to populate a menu.Please give me a code of controller class and jsp: i use hibernate and tile to this sample.
i tired
public String listmaintabAndsubtabs(Map<String, Object> map) {
map.put("maintab", new maintab());
map.put("maintabList", contactService.listmaintab());
return "maintab";
}
how to to return subtabs and main tabs both by one method....
Why do you want to return only a list, use map instead.
In your controller you can use,
in your jsp, you can iterate the map,
EDIT :
Once you have two list, you can iterate them, in multiple ways,
you can use
for (X obj: childLst) { // X indicates the class of object the list contains System.out.println(obj); }
you can also use iterator to loop through the list.