spring HibernateValidator 验证 子类不起作用,在要验证的子类前加上@Valid即可。


public class UserInfo {

private int Id;
@Valid
private AccontInfo accountInfo;
@NotEmpty(message="{Title.FirstName}{Validator.CanNotBeEmpty}")
private String FirstName;
private String LastName;
@Pattern(regexp="/^1[0-9]{10}$/",message="{Title.PhoneNo} {Validator.ErrorFormate}")
private String PhoneNo;
private int Gender;

posted on 2016-02-17 12:23  xuxu_dragon  阅读(1381)  评论(0编辑  收藏  举报