Get hold of Spring model from everywhere
In a controller I can get model by declaring Model/ModelMap typed parameter. In handler interceptors and in view rendering I get the same. But how do I get the model from the arbitrary class, which can get hold of Application开发者_如何学运维Context or web request? I just don't want to use model.addAttribute() all the time and would like my service automatically put objects into model.
The idea is that you shouldn't. Your controllers are the entry point of your application, so you get them there, and pass them as arguments to the layers below.
精彩评论