Which is better, return “ModelAndView” or “String” on spring3 controller

There is no better way. Both are perfectly valid. Which one you choose to use depends which one suits your application better – Spring allows you to do it either way.

Historically, the two approaches come from different versions of Spring. The ModelAndView approach was the primary way of returning both model and view information from a controller in pre-Spring 2.0. Now you can combine the Model parameter and the String return value, but the old approach is still valid.

Leave a Comment

tech