How to user Hibernate @Valid constraint with Spring 3.x?

Posted by Burak Dede on Stack Overflow See other posts from Stack Overflow or by Burak Dede
Published on 2009-11-20T12:08:26Z Indexed on 2010/03/19 2:01 UTC
Read the original article Hit count: 458

I am working on simple form to validate fields like this one.

public class Contact {

    @NotNull
    @Max(64)
    @Size(max=64)
    private String name;

    @NotNull
    @Email
    @Size(min=4)
    private String mail;

    @NotNull
    @Size(max=300)
    private String text;


}

I provide getter and setters hibernate dependencies on my classpath also.But i still do not get the how to validate simple form there is actually not so much documentation for spring hibernate combination.

@RequestMapping(value = "/contact", method = RequestMethod.POST)
public String add(@Valid Contact contact, BindingResult result) {
    ....
}

Could you explain it or give some tutorial , except original spring 3.x documentation

© Stack Overflow or respective owner

Related posts about spring

Related posts about hibernate