Code example for ModelAndView

Methods: addObjectsetViewName

0
	@RequestMapping("/deleteCollection") 
	public ModelAndView deleteCollection(HttpServletRequest request, HttpServletResponse response) throws Exception {
		 
		collectionManageService.deleteCollectionInfo(request.getParameter("collectionName"));
		 
		ModelAndView modelAndView = new ModelAndView();
		 
//		CrescentCollectionHandler collectionHandler  
//			= SpringApplicationContext.getBean("crescentCollectionHandler", CrescentCollectionHandler.class); 
		 
		CrescentCollections crescentCollections = collectionHandler.getCrescentCollections();
		String selectedCollectionName = crescentCollections.getCrescentCollections().get(0).getName();
		 
		modelAndView.addObject("selectedCollectionName", selectedCollectionName);
		modelAndView.addObject("crescentCollectionList", crescentCollections.getCrescentCollections());
		modelAndView.addObject("selectedCollection", crescentCollections.getCrescentCollection(selectedCollectionName));
		 
		modelAndView.setViewName("/admin/collectionManageMain");
		 
		 
		return modelAndView;
	} 
}