I have some common components that are always present in every page served by a given Controller class.
At the beginning of each @RequestMapping method I populate the model with these common components.
Is there a way to define a method be called prior to each of the controller methods so that I can get all of this copy/paste into one place?
Just annotate a method with
@ModelAttributeThe below would add a Foo instance to the model under the name “foo”
See the
@ModelAttributedocumentation