开发者

SpringMVC: Can I specify a @ModelAttribute be populated only for specific controller methods?

开发者 https://www.devze.com 2023-02-20 19:06 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消