以下验证是否意味着该字段不能为 null?( @Size 注释 )
2022-09-02 03:39:46
我在我的春季MVC表单bean中有以下属性,使用来验证表单bean,如下所示:javax.validation.constraints
public class MyForm {
@Size(min = 2, max = 50)
private String postcode;
// getter and setter for postcode.
}
我的问题是:这是否意味着属性不能,因为它总是需要大于2的长度。我之所以这么说,是因为在同一个包中有一个约束,因此,如果我在上面的bean中使用它,那么约束是多余的。@Size(min = 2)
null
@NotNull
@NotNull