I am building an application using Spring MVC. I want to make certain changes to my model for each controller in the application. In particular, I want to insert some additional data into the model, which will be present on all pages of the application.
I could do this in several ways: just add data to the end of each controller, use a subclass of the model that adds my extra data, use a subclass of ModelAndView that wraps my model, uses a subclass of VelocityView that wraps the Model before using it ... I'm sure that there are other options.
But I have a limitation of "elegance": I do not want to write code in each controller, I want this behavior to be defined in one- and only one . Ideally, this will be controlled by my IOC bean configuration file.
Does anyone have a recommendation on how to achieve this elegantly?
source
share