• 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

*参考链接:

http://stackoverflow.com/questions/17137307/in-hibernate-validator-4-1-what-is-the-difference-between-notnull-notempty

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

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

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

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

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

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

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

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

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

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

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

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

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

  7. 开发中常见的@NotNull,@NotBlank,@NotEmpty注解的区别

    开发中常看见@NotNull,@NotBlank,@NotEmpty三个注解,但却没有深入了解过,下面介绍一下他们的应用场景和区别 @NotNull:主要用在基本数据类型上(Int,Integer,D ...

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

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

  9. @NotNull @NotEmpty @NotBlank区别

    @interface NotNull The annotated element must not be {@code null}.Accepts any type.----------------- ...

随机推荐

  1. Unable to start T-SQL Debugging. Could not connect to the computer ‘.’

    Unable to start T-SQL Debugging. Could not connect to the computer ‘.’ 在Win7上面使用SSMS连接到SQL Server使用D ...

  2. android引导页的实现 及跳转到主页面

    第一个activity package com.qualitypicture.activity; import java.util.ArrayList; import java.util.List; ...

  3. 框架基础:ajax设计方案(三)---集成ajax上传技术

    之前发布了ajax的通用解决方案,核心的ajax发布请求,以及集成了轮询.这次去外国网站逛逛,然后发现了ajax level2的上传文件,所以就有了把ajax的上传文件集成进去的想法,ajax方案的l ...

  4. 在android里用ExpandableListView实现二层和三层列表

    转载自http://www.cnblogs.com/nuliniaoboke/archive/2012/11/13/2767957.html 二层列表是直接用androidAPI中的Expandabl ...

  5. c数据结构学习随笔

    #include <stdio.h> #include <stdlib.h> #include "PublicDS.h" #include<Windo ...

  6. 基于TcpListener实现最简单的http服务器

    最近实现一套简单的网络程序.为了查看程序内部的变量,方便调试.就在想搞一个最最简单的方式.第一个想到写文件,日志.这个不实时,而且打开麻烦,pass .于是想到用网络输出.本来是想写成c/s模式,想着 ...

  7. CSS3样式linear-gradient的使用

    linear-gradient linear-gradient是CSS3中新增的样式,主要用于颜色的渐变效果.MDN地址 linear-gradient在不同内核下使用方式不同,详细内容可参考w3cp ...

  8. List转换为DataTable

    public static DataTable ListToDataTable(IList list) { DataTable result = new DataTable(); if (list.C ...

  9. Help improve Android Studio by sending usage statistics to Google

    Please press I agree if you want to help make Android Studio better or I don't agree otherwise. more ...

  10. 自定义Dialog,从下面弹出

    Window window= getWindow(); 只要 打开一个Activity 就有一个窗口存放这个Activity ,手机又很多个窗口,不只是一个窗口 import android.app. ...