Announcement Announcement Module
No announcement yet.
How to create default beans accessible by every page ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create default beans accessible by every page ?

    I would like to have certain objects accessible in every page of my webapp.
    I have a JavaScript menu that I want to generate dynamically from the DB, and as the menu is on every page, I will need the DAo object in every page.

    Ideally I could use <jsp:useBean> tag to retrieve them in the page.

    What is the best way to achieve this ?

    Do I need to place them in the ModelAndView in every controller that I have, or should I override DispatcherServlet and stick them in the page context ?

    But how about simple JSP files that do not use controller ?

    Thanks for any help


  • #2
    one way is to have an interceptor which will stick these objects in the model in postHandle method:
    	modelAndView.addObject&#40;"objectName", objectValue&#41;;