@NotNull和@NotEmpty和@NotBlank区别
2016-07-20 22:44
288 查看
-
1.@NotNull:不能为null,但可以为empty
(""," "," ")
-
2.@NotEmpty:不能为null,而且长度必须大于0
(" "," ")
-
3.@NotBlank:只能作用在String上,不能为null,而且调用trim()后,长度必须大于0
("test") 即:必须有实际字符
*
@NotNull: The CharSequence, Collection, Map or Array object is not null, but can be empty. @NotEmpty: The CharSequence, Collection, Map or Array object is not null and size > 0. @NotBlank: The string is not null and the trimmed length is greater than zero.
-
4.examples:
1.String name = null; @NotNull: false @NotEmpty:false @NotBlank:false 2.String name = ""; @NotNull:true @NotEmpty: false @NotBlank: false 3.String name = " "; @NotNull: true @NotEmpty: true @NotBlank: false 4.String name = "Great answer!"; @NotNull: true @NotEmpty:true @NotBlank:true
*参考链接:
相关文章推荐
- APP开发实战112-ProGuard注意事项
- ORACLE PL/SQL 实例精解之第二章 通用编程语言基础
- 114. Flatten Binary Tree to Linked List
- 2系统启动后的 wifi加载 过程-图解
- 百练 01 Charm Bracelet
- Android IPC 进程间通信
- java.net.SocketTimeoutException: Read timed out
- APP开发实战111-ProGuard指令介绍
- android多选项表对话框
- Nuts & Bolts Problem
- 用户控件UserControl图片资源定位(一)---Xaml引用图片
- servlet中的中文乱码问题
- Python学习-2天--字符串操作
- android:常用Toast详解
- hibernate,java,数据库类型对应关系
- opencv学习(4)部分基本数据结构的介绍
- github报错failed to push some refs to 'git
- 【MAVEN】使用maven创建web项目详细记录
- 基于linux-2.6.38.8内核的SDIO/wifi驱动分析
- 织梦DedeCMS v5.7全文检索使用说明