The usage of ModelAndView ModelMap and Model to store values

The usage of ModelAndView ModelMap and Model to store values

 

1. Usage of ModelAndView

 

It cannot be placed directly in the parameters of the method, but needs to be created by new in the method.

 

The object ModelAndView can be created directly in the method  mv = new ModelAndView () ;

 

Put the value that the page needs to get into the mv through the addObject method .

Direct return mv     points to that page,

 

Find the corresponding page by the name of the annotation on the class name / the name of the annotation on the method.

It finds the page by splicing the annotation name on the class and the annotation name on the method to find the page

 

2.ModelMap is exactly the same as the usage of model. Whoever assigns the value last will take it first.

 

Store the value in the addAttribute method


  Model and ModelMap find the page through the return value. model.addAttribute("user",User);

You can get the user's object through ${user} in the foreground

 

Guess you like

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