Demand Scene: When users log in, enter the name of the wrong user name and password needed message appears on the landing page.
The first method: landing unsuccessful, return directly to the page, you can get directly to the Map by thymeleaf error message
The second method: using RedirectAttributes
attributes.addFlashAttribute ( " loginFailMsg " , " 1001: user name and password do not match, please re-enter ~ ~ " ); attributes.addAttribute ( " the Test " , " the Test " );
FIG results are as follows: Use the addAttribute () method, will be assembled into the url parameter, which will expose the parameter name and value, and therefore this method is not recommended
Use addFlashAttribute () to hide the parameters passed
After using addFlashAttribute (), obtaining parameters, parameters need to increase HttpServletRequest Controller process; RequestContextUtils.getInputFlashMap acquired FlashMap is final not be modified.
String loginFailMsg = (String) RequestContextUtils.getInputFlashMap(request).get("loginFailMsg");