开发者

Can I chain two spring controllers together, each doing partial retrieval of data for the page?

I have two controllers that each do a separate action, retrievi开发者_StackOverflow中文版ng data for my page. Can I chain them together and pass the data from the first to the second?


Looks like you have given a lot of responsibilities to your controllers. After all, a controller should delegate responsibility of building model (data) to others and should mainly focus on matching model with view. It should not even be aware of how model is built and how a view would be rendered. I think some refactoring is needed so that instead of requiring some chaining, you could use the same model builder in both controllers.

Having said that, of course, you can pass data from one controller to other and most popular way is to use redirect or forward. Please also see Programmatically call @Controller.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜