I’m trying to implement my first Spring MVC controller, following Spring documentation, some tutorials and the “Spring in Action” book.
Now I have a doubt: implementing the controller methods I find differences in handling the model.
Sometimes they use a Map<String, Object>, a Model object or else a ModelAndView object.
Which is the difference among using an object or another?
Which is the reason for choosing one instead of another?
ModelAndView, contains the model, and the name of the view. ModelMap, in contract, only contains information about the model.
So with model and view you can explicity set the view name.
If you just set up the model and return a string in your controller , the view name is inferred from the request uri.