Announcement Announcement Module
Collapse
No announcement yet.
Model Object Inheritance? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Model Object Inheritance?

    I have a bunch of controller methods in one class all need to add the same session attribute to the Model for front end UI to use. To avoid repetitively add " model.addAttribute("isAdmin", session.getAttribute("isAdmin"));" and add HttpSession session to every method header, what is the best way to do it? I am thinking of extending the Model, but I am not sure how to implement it. Thanks!
    ex:
    Code:
    	
    @RequestMapping("/setUpForm.html")
    public String setupForm(Model model, HttpSession session) {
            model.addAttribute("isAdmin",  session.getAttribute("isAdmin"));		
    	model.addAttribute(...);
    	model.addAttribute(...);		
    	return ....
    }
Working...
X