SpringMVC: Can I specify a @ModelAttribute be populated only for specific controller methods?
We have a couple of attributes that are common to 90% of the pages in our webapp.
I'd like to simply declare an @ModelAttribute("userCredits")
on my controller to populate this common attribute.
However, for some pages I don't need this attribute. Can I avoid it being populated (it's modestly expensive to generate) in the one-off cases when it's not required?
I'm not a big fan of it being populated non-declaratively 开发者_开发技巧on every call, but I don't like the copy-paste addition of methods in each controller-handler to populate it either.
I'm pretty confident there is no such support, which is also supported by observing the available annotations from the spring javadoc
精彩评论