Code example for ModelAndView

Methods: addObjectsetViewName

0
		return mv;
	} 
	 
	@RequestMapping(value="/manager/addclasses",method=RequestMethod.POST)
	public ModelAndView addClasses(Classes classes){
		ModelAndView mv=new ModelAndView();
		Classes cls = classesService.findClassesById(classes.getId());
		if(null==cls){
			mv.setViewName("redirect:/manager/classes");
			classes.setStudentcount(0);
			classesService.addClasses(classes);
		}else{ 
			mv.setViewName("redirect:/manager/addclassespage");
			mv.addObject("name", classes.getName());
			mv.addObject("headteacher", classes.getHeadteacher());
			mv.addObject("notice","已存在编号为"+classes.getId()+"的班级");
		} 
		return mv;
	} 
	 
	@RequestMapping(value="/manager/managerstudentpage",method=RequestMethod.GET)