I have seen that annotation like @NotNull etc are given in JSR Specifications.
Now as i am currently studying Spring MVC and building website in that
so i am confused are they same or different and have they any relation with spring MVC.
because for .eg if i use @NotEmpty then will spring knows that if i leave it empty then it displays in form with error message like we code in validator and its messages
This is my method , i am confused were to add @Valid
public String add(@ModelAttribute("personAttribute") Person person) {
logger.debug("Received request to add new person");
personService.add(person);
// This will resolve to /WEB-INF/jsp/addedpage.jsp
return "hibernate/addedpage";
}
Spring form validation is different, but it also support JSR-303 validation. You can validate a whole model attribute by annotating it with
@Valid
(as a method parameter)You would need:
<mvc:annotation-driven />
in the spring-mvc xml to enable validation