I am not able to get spring validation errors displayed on the jsp page. Here is my code. On the jsp page, when I enter a empty name, the controller code does return a ModelAndView with errors, it just doesn't display it on the jsp page.
Any help would be greatly appreciated. Thank you!
@RequestMapping(value = "/editTag.htm", method = RequestMethod.POST)
public ModelAndView editTag(@ModelAttribute("Tag") Tag tag) {
BindingResult result = new BeanPropertyBindingResult(tag, "tag");
ValidationUtils.rejectIfEmptyOrWhitespace(result, "name", "field.required", "Tag Name is required");
if (result.hasErrors()) {
return new ModelAndView("tag.edit").addObject("tag",tag).addObject("errors", result);
}
tagDao.merge(tag);
return new ModelAndView("redirect:/tags/listTags.htm");
}
<form:form commandName="tag">
<form:errors path="name"/><br />
<form:input path="name" size="30" />
...
</form:form>