1. @NotEmpty:用于 String、集合、Map、数组
Asserts that the annotated string, collection, map or array is not {@code null} or empty.
加了@NotEmpty的String类,Collection、Map、数组,是不能为null或者长度为0的(String、Collection、Map
的isEmpth()方法)
2. @NotBlank:用于String
Validate that the annotated string is not {@code null} or empty.
The difference to {@code NotEmpty} is that trailing whitespaces are getting ignored.
“The difference to {@code NotEmpty} is that trailing whitespaces are getting ignored.” –> 和{@code NotEmpty}不同的是,尾部空格被忽略,也就是说,纯空格的String也是不符合规则的。所以才会说@NotBlank用于String。
3.NotNull:可用于所有类型,参数不能为null
The annotated element must not be {@code null}.
Accepts any type.