Skip to main content

ModelAndView

Learn ModelAndView (DispatcherServlet, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes ModelAndView is a holder object that carries both the model data and the view (name or object) back to DispatcherServlet in one return value. Creation : new ModelAndView("home", "msg", "Hi") sets the view name plus one attribute; addObject adds more. Result : DispatcherServlet reads the view and model from it, resolves the view and renders it.

More lessons in DispatcherServlet