Code example for ModelAndView

Methods: addObjectsetViewName

0
	} 
	 
	 
	@RequestMapping(value="/login",method=RequestMethod.POST)
	public ModelAndView login(String username,String password,HttpServletRequest request){
		ModelAndView mv=new ModelAndView("");
		if( USERNAME.equals(username)&& PASSWORD.equals(password)){
			request.getSession().setAttribute("user", username);
			mv.setViewName("redirect:/manager/students");
		}else{ 
			mv.setViewName("forward:/");
			mv.addObject("username",username);
			mv.addObject("message", "username or password error ");
		} 
		return mv;
	} 
	 
	 
	@RequestMapping(value="/loginout",method=RequestMethod.POST)
	public ModelAndView loginOut(HttpServletRequest request){
Experience pair programming with AI  Get Codota for Java