@RequestMapping(value = "/test", method = RequestMethod.POST)
public String test(@Validated SysUser sysUser, BindingResult result, RedirectAttributes attr) {
try {
if (result.hasErrors()) {
Map<String, String> errors = buileValidatedMessage(result);
attr.addFlashAttribute("errMsg", errors);
}
} catch (Exception e) {
e.printStackTrace();
}
return "redirect:/index.jsp";
}
我这样写好,在页面无法获取到数据呀
<form action="${CTX}/test.do" method="post">
<input name="fdUsername">${errMsg.fdUsername}<br>
<input name="fdPassword">${errMsg.fdPassword}<br>
<input type="submit" value="提交">
</form>
在controller里可以正常打印错误,就是跳到页面无法获取。