@NotEmpty、@NotBlank、@NotNull三种注解的区别
@NotEmpty
@NotEmpty用在集合类上面,加了@NotEmpty的String类、Collection、Map、数组,
是不能为null或者长度为0的(String Collection Map的isEmpty()方法)
NotBlank
The annotated element must not be {@code null} and must contain at least one
non-whitespace character.
带注释的元素不能为{@code null},并且必须至少包含一个非空白字符。
用于String,不能为null且trim()之后size>0
@NotNull
The annotated element must not be {@code null}. Accepts any type.
带注释的元素不能为{@code null}。 接受任何类型。
@NotNull 不能为null,但可以为empty,没有Size的约束

浙公网安备 33010602011771号