Redirect should be done after success, not after failure
rstoyanchev opened this issue · comments
Rossen Stoyanchev commented
Currently the controller method is implemented to redirect after validation failure and does not on success. It should be the other way around.
Something like this:
@RequestMapping(value="/", method=RequestMethod.POST)
public String enterAge(@Valid Person person, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "results";
}
return "redirect:/";
}
Greg L. Turnquist commented
Guide has been updated based on @rstoyanchev 's tips.