I always use an approach in which controller methods return ModelAndView . Just because it usually makes controller methods a bit more concise. Method parameters are now strictly input . And all the associated output data is contained in the object returned by the method.
The ModelAndView style seems to resonate with people who don't like updating the input parameters for a method. Adhering to the belief that this will be a side effect, a dangerous pattern, because you cannot reliably predict what this method will do, it can return data in the returned object, or it could update anything in any of the input arguments .
So, some people still prefer ModelAndView .
New style with Model as a method parameter and return string as the name of the view. This seems to come from a slightly different design approach. Here, model objects are considered a type of event or element that is passed to several handlers before returning to the view where they are displayed. It reminds me of how events are handled in the AWT / Swing world. This model is more consistent with an approach in which several handlers can be built on top of Model objects until a view is reached.
Thus, at the end of the day, there seems to be no definite reason to criticize or promote any approach. You should use a style that more closely matches your overall design philosophy.
Hope this helps.
Akshay Jun 06 '13 at 10:41 2013-06-06 10:41
source share