My Current status.
1.Fetch all the menu from DB, as a Map contains key as main menu and set as submenus. 2.While Loading Welcome.jsp, main menu Item will display from key of the map and keep this map in session. 3.on click of main menu I will call an Jquery Ajax call to display the sub menu Item, the same time my color change of main menu is happening. Upto this I have achieved Now the challenge as below 1.If I click on another submenu Item, I dont want to change the main menu status-need to retain the color change. 2.How can I retain this menus in all the pages with minimum effort.
So here what you can do
If possible post your code we can go from there.
I would approach this with a class to represent the Menus, and a ControllerAdvice to add this info in all pages needed of your application. The Menu class can be something like:
class Menu{
String href;
List<Menu> subitems = new ArrayList();
}
Then when rendering the jsp, you can organize it the way you described.
About the @ControllerAdvice, you can add things to the pages model. It's useful if this menu shows up in a lot of pages.