The difference between sringMVC Model ModelMap and ModelAndView

Recently, I was looking at the code and found that there are different ways to process the returned data in the controller, and I have been using ModelAndView to process data, and I have used other methods sporadically, but I always feel that I don't understand the difference, so I wrote this This blog summarizes:

simply put:

Model is an interface that contains four addAttribute and one merAttribute methods.

ModelMap : Implements the Map interface, including the Map method. The view layer finds the data in the ModelMap through the request.

ModelAndView: is a container that contains ModelMap and view objects. As the name implies, it contains both the model and the view, while the ModelMap just contains information about the model.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324974241&siteId=291194637