@RequestMapping(value = "/showCars", method = RequestMethod.GET)
public ModelAndView showApp() {

    ModelAndView modelAndView = new ModelAndView();

    //adding a single attribute for the modelMap
    PageContent pageContent = new PageContent();
    pageContent.setHeaderName("All Cars - From Controller");
    modelAndView.addObject(pageContent);

    List<Car> carList = new ArrayList<>();

    Car car1 = new Car();
    car1.setModel("Toyota");
    car1.setRegNo("223456");
    car1.setYear("2005");

    Car car2 = new Car();
    car2.setModel("Mazda");
    car2.setRegNo("24244");
    car2.setYear("2015");

    Car car3 = new Car();
    car3.setModel("Nissan");
    car3.setRegNo("4465757");
    car3.setYear("2013");

    carList.add(car1);
    carList.add(car2);
    carList.add(car3);

    Map<String,Object> allObjectsMap = new HashMap<String,Object>();
    allObjectsMap.put("allCarObjects", carList);

    //adding a set of objects for the model map
    modelAndView.addAllObjects(allObjectsMap);

    modelAndView.setViewName("CarView");
    return modelAndView;
}

        

public ModelAndView handleRequest(final HttpServletRequest request,
		final HttpServletResponse response) throws Exception {
	ModelAndView modelAndView = null;
	User user = new User();
	user.setAge(10);
	user.setName("Dummy user");

	User autoUser = new User();
	autoUser.setAge(11);
	autoUser.setName("Auto");

	String conTime = "CON TIME";
	//the view, attribute name and value
	modelAndView = new ModelAndView("data", "model", user);
	modelAndView.addObject(autoUser);//just the attribute - name auto-generated

	modelAndView.addObject("tpVariable", conTime);//atribute and name

	User testUser = new User();
	testUser.setAge(61);
	testUser.setName("Test user");

	Map<String, Object> modelMap = new LinkedHashMap<String, Object>();
	modelMap.put("testValue", "testValue");
	modelMap.put("int", 10);
	modelMap.put("tUser", testUser);

	modelAndView.addAllObjects(modelMap);// a map of attributes
	return modelAndView;
}

        

@RequestMapping("/test")
public ModelAndView test(){
	Map<String, String> model = new HashMap<String, String>();
	ModelAndView modelAndView = new ModelAndView("TestPage");
	model.put('var1', "test1");
	model.put('var2', "test2");
	modelAndView.addAllObjects(model);
	return modelAndView;
}

        

public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String id = req.getParameter("id");
	Player player = service.getPlayer(id);

	Map<String, Object> model = new HashMap<String, Object>();
	model.put("player", player);

	ModelAndView modelAndView = new ModelAndView();
	modelAndView.setViewName("/WEB-INF/views/player/test.jsp");
	modelAndView.addAllObjects(model);

	return modelAndView;
}

        

public ModelAndView list(HttpServletRequest req,
		HttpServletResponse resp) throws Exception {

	String name = req.getParameter("name");

	List agendaEntries = agendaEntryDAO.find(name);            
	Map model = new HashMap();        
	ModelAndView modelAndView = new ModelAndView();
	model.put("jsonResponse", agendaEntries);   
	modelAndView.addAllObjects(model);
	View jsonView = new JSONView();
	modelAndView.setView(jsonView);
	return modelAndView;        
}

        

private ModelAndView generateSuccessView(final Assertion assertion, final String proxyIou,
                                         final WebApplicationService service,
                                         final TicketGrantingTicket proxyGrantingTicket) {

    final ModelAndView modelAndView = getModelAndView(true, service);

    modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, assertion);
    modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, service);
    modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET_IOU, proxyIou);
    if (proxyGrantingTicket != null) {
        modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_PROXY_GRANTING_TICKET, proxyGrantingTicket.getId());
    }
    final Map<String, ?> augmentedModelObjects = augmentSuccessViewModelObjects(assertion);
    if (augmentedModelObjects != null) {
        modelAndView.addAllObjects(augmentedModelObjects);
    }
    return modelAndView;
}

        

@ExceptionHandler(BusinessException.class)
ModelAndView handleExceptionView(BusinessException exception, HttpServletResponse response) {
    response.setStatus(exception.getStatus());
    ModelAndView modelAndView = new ModelAndView("error/" + exception.getStatus());
    modelAndView.addAllObjects(ResponseMessage.error(exception.getMessage(), exception.getStatus()).toMap());
    modelAndView.addObject("exception", exception);
    modelAndView.addObject("absPath", WebUtil.getBasePath(WebUtil.getHttpServletRequest()));
    return modelAndView;
}

        

public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
    ModelAndView errorMav;
    logger.debug("resolving Exception");
    if (ex instanceof ValidationException) {
        logger.debug("is a ValidationException");
        ValidationException ve = (ValidationException) ex;
        errorMav = new ModelAndView(ve.getViewName());
        errorMav.addObject(errorMessageKey, ve.getErrorMessageKey());
        errorMav.addAllObjects(ve.getModelElements());
        return errorMav;
    } else if (ex instanceof IllegalArgumentException) {
        errorMav = new ModelAndView("editStep2");
        errorMav.addObject("error", "ERROR: " + ex.getMessage());
        return errorMav;
    //return new ModelAndView("arraystoreView");
    } else
        return null;
}

        

@RequestMapping(value = "/article/show")
public ModelAndView show(@RequestParam final Integer id) {
	final ModelMap modelMap = new ModelMap();

	final Collection<Category> categories = this.categoryDao.find();
	modelMap.addAttribute("categories", categories);
	modelMap.addAttribute("article", this.articleDao.getById(id));

	return new ModelAndView("showArticle" /* JSP généré */)
			.addAllObjects(modelMap);
}

        

public ModelAndView handleRequest(HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	ModelAndView result = new ModelAndView();
	result.setViewName(view);

	Map<String, Object> model = new HashMap<String, Object>();
	model.put("appConfig", config);
	model.put("server", server);
	model.put("memory", new MemoryInfo());
	result.addAllObjects(model);

	return result;
}        
main