Spring MVC complex model population from multiple sources

后端 未结 5 2228
不思量自难忘°
不思量自难忘° 2020-12-30 09:36

Well, my question may sound a little bit fuzzy, but here it is, anyways. I\'m building a web application using Spring MVC 3.1.M1, JSP 2.1 (without Tiles, I use plain JSP tag

5条回答
  •  情书的邮戳
    2020-12-30 10:09

    well you have several options, though they are not perfect either..

    1. abstract controller like you mentioned
    2. create a service that will return you the model data.. now youve moved the problem into the service layer where it arguably doesnt belong, but at least your controllers can just make one service call during each controller method.
    3. create a filter and populate the common parts of the model in the filter.
    4. you can probably create some monster with annotations, for example, annotate the controller methods and then post processes the controller objects to inject the data in (this, i am not sure how to do exactly, but there must be a way)
    5. spring AOP might be able to help you do #4 more gracefully

    these are just some ideas to get some discussion going

提交回复
热议问题