@NotEmpty 用在集合上面(不能注释枚举)

@NotBlank用在String上面

@NotNull用在所有类型上面

1. @NotEmpty

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

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

The annotated element must not be {@code null}.

Accepts any type.

这个就很好理解了,不能为null。

@NotEmpty、@NotNull、@NotBlank 的区别的更多相关文章

  1. @NotNull、@NotEmpty、@NotBlank的区别

    Spring中@NotNull.@NotEmpty.@NotBlank的区别@NotNull:用于基本数据类型@NotEmpty:用于集合类@NotBlank:用于String上面

  2. spring boot -表单校验步骤 +@NotEmpty,@NotNull和@NotBlank的区别

    1.实体类属性上添加注解规则 如 public class User { @NotBlank private Integer id ; 2.在方法中添加注解@Valid和一个校验结果参数(Bindin ...

  3. @NotNull,@NotEmpty,@NotBlank区别

    示例结果: // null String name = null; @NotNull: false @NotEmpty: false @NotBlank: false // 空字符串 String n ...

  4. @NotNull和@NotEmpty和@NotBlank区别

    1.@NotNull:不能为null,但可以为empty (""," "," ") 2.@NotEmpty:不能为null,而且长度必须大于 ...

  5. @NotEmpty、@NotNull 和 @NotBlank 的区别

    1. 三者主要区别如下: @NotEmpty :用于集合类,不能为null,且size>0 @NotNull:不能为null,但可以为empty,没有size的约束 @NotBlank:只用于S ...

  6. Hibernate Validator验证框架中@NotEmpty、@NotBlank、@NotNull 的区别

    Hibernate Validator验证框架中@NotEmpty.@NotBlank.@NotNull的主要使用情况 @NotEmpty  用在集合类上面 @NotBlank   用在String上 ...

  7. Spring 中@NotNull, @NotEmpty和@NotBlank之间的区别是什么?

    简述三者区别 @NotNull://CharSequence, Collection, Map 和 Array 对象不能是 null, 但可以是空集(size = 0). @NotEmpty://Ch ...

  8. @NotNull, @NotEmpty和@NotBlank之间的区别是什么?

    首先是简要描述: [java] view plain copy@NotNull://CharSequence, Collection, Map 和 Array 对象不能是 null, 但可以是空集(s ...

  9. @NotEmpty、@NotBlank、@NotNull的区别

    @NotEmpty 用在集合类上面  @NotBlank 用在String上面  @NotNull 用在基本类型上 只有简单的结果,但是再更具体一点的内容就搜不到了,所以去看了看源码,发现了如下的注释 ...

  10. @NotNull和@NotEmpty和@NotBlank 区别

    1.@NotNull:不能为null,但可以为empty:用在基本类型上. 2.@NotEmpty:不能为null,而且长度必须大于0:用在集合类上面. 3.@NotBlank:只能作用在String ...

随机推荐

  1. python set_index与reset_index的妙用

  2. Redis Intro - Skiplist

    http://zhangtielei.com/posts/blog-redis-skiplist.html https://juejin.im/entry/59197a390ce4630069fbcf ...

  3. [转]asp.net URL中包含中文参数造成乱码的解决方法

    本文转自:http://www.jb51.net/article/22437.htm 问题: 前段时间,在系统中做了一个类似于友情链接的功能块,一直运行良好,直到有一天加了类似于以下的链接地址:htt ...

  4. [转]jQuery AJAX pagination plugin with ASP.NET Server Side

    本文转自:http://do-web.com/jpaging/usage How does it work? 1. In order to implement the plugin, you need ...

  5. LeetCode 62.不同路径(C++)

    一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为“Finish”). 问总共有多 ...

  6. rsync+inotify实现数据的实时同步更新

    rsync可以实现触发式的文件同步,但是通过crontab守护进程方式进行触发,同步的数据和实际数据会有差异,而inotify可以监控文件系统的各种变化,当文件有任何变动时,就触发rsync同步,这样 ...

  7. iOS 时间戳和时间互换,计算两日期相隔天数

    /*  *获取当前系统时间的时间戳  */ +(NSInteger)getNowTimestamp;   /**  * 获取当前时间  */ + (NSString *)getNowTimeTampF ...

  8. Spring的注解积累

    需要在applicationContext.xml中注册: 如:在base-package指明一个包 <context:component-scan base-package="cn. ...

  9. 关于hibernate save方法未能存储数据入库的处理过程

    关于hibernate save方法未能存储数据入库的处理过程2018年04月18日 10:57:49 守望dfdfdf 阅读数:230更多个人分类: 工作 问题编辑版权声明:本文为博主原创文章,转载 ...

  10. 粗看ES6之函数

    标签: es6 javascript 箭头函数 ES6为了书写方便引入了函数的全新简写方式-箭头函数 <!DOCTYPE html> <html> <head> & ...