RedirectAttributes only work with RedirectView, please follow the same
@RequestMapping(value="/Login",method = RequestMethod.POST)
public RedirectView loginValidate(HttpServletRequest req, RedirectAttributes redir){
...
redirectView= new RedirectView("/foo",true);
redir.addFlashAttribute("USERNAME",uname);
return redirectView;
}
Those flash attributes are passed via the session (and are destroyed immediately after being used – see Spring Reference Manual for details). This has two interests :
- they are not visible in URL
- you are not restricted to String, but may pass arbitrary objects.