81,092
社区成员
发帖
与我相关
我的任务
分享
@RequestMapping(value = "/test1", method = RequestMethod.POST)
public String test1(@Validated SysUser sysUser, BindingResult result, RedirectAttributes attr) {
String url = "redirect:/index.jsp";
try {
if (result.hasErrors()) {
Map<String, String> errors = buileValidatedMessage(result);
System.out.println(errors);
attr.addFlashAttribute("errMsg", errors);
attr.addFlashAttribute("myinfo", "123456789");
attr.addAttribute("info", 55);
}
} catch (Exception e) {
e.printStackTrace();
}
return url;
}
<h2>Hello World!</h2>
<h3>1.${myinfo}</h3>
<h3>2.${errMsg}</h3>
<h3>3.${info}</h3>
<%
Enumeration<String> names1 = session.getAttributeNames();
while (names1.hasMoreElements()) {
String name = names1.nextElement();
out.println(name + " : " + session.getAttribute(name) + "<br>");
}
%>
org.springframework.web.servlet.support.SessionFlashMapManager.FLASH_MAPS : [FlashMap [attributes={errMsg={fdPassword=密码不能空, fdUsername=用户名不能空;用户名长度必须在3~10个字符之间}, myinfo=123456789}, targetRequestPath=/smart/index.jsp, targetRequestParams={info=[55]}]]