如何在发生任何验证错误时处理重定向的表单提交 我在叠加层中创建了表单,其中包含如何在叠加层上显示错误的字段。因为在提交表单后如果发生任何错误,它将返回注册页面,因此如何显示Overlay open 这是代码
@RequestMapping(value = "/register", method = RequestMethod.GET)
public void registerForm(Model model) {
model.addAttribute("registerInfo", new UserRegistrationForm());
}
@RequestMapping(value = "/reg", method = RequestMethod.POST)
public String create(
@Valid @ModelAttribute("registerInfo") UserRegistrationForm userRegistrationForm,
BindingResult result) {
if (result.hasErrors()) {
return "register";
}
userService.addUser(userRegistrationForm);
return "redirect:/";
}