java - Spring MVC: Insert values into all my ModelAndView s -


I have a mid-sized spring application and I add key / value pairs to all the models and scenes in cross cutting fashion I want to include (like AOP).

Inspiration is to add all the pages (configuration values, build numbers, etc.).

What is the easiest way to do this? I prefer without AOP but I am ready to use it if necessary.

You have several options here. /

  1. Write a custom handler interceptor , and override the posthand () method, supply your data to ModelAndView .
  2. If your data is static, you can use it in ViewResolver in attributes to UrlBasedViewResolver . This is useful only for real string-based configs that you can put in your beans file.
  3. With a @ModelAttribute a method has been commented in your controller. Any object returned from such annotated methods is automatically added to the model. This will be done only for those requests managed by the @Requestmapping -annotated methods in that controller class.

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -