Code example for ModelAndView

Methods: addObjectsetViewName

0
public class HelloWorldController implements Controller { 
 
	@Override 
	public ModelAndView handleRequest(HttpServletRequest request, 
			HttpServletResponse response) throws Exception { 
		ModelAndView modelAndView = new ModelAndView(); 
		modelAndView.setViewName("helloWorld"); 
		String message = "Done! Spring MVC works like a charm! : - ) "; 
		modelAndView.addObject("message", message); 
		return modelAndView; 
	} 
 
} 
Contextual code suggestions in your IDE  Get Codota for Java