当前位置:网站首页>@Notblank, @notnull, @notempty differences and uses
@Notblank, @notnull, @notempty differences and uses
2022-07-26 10:47:00 【Eric-x】
Through annotation, we can verify the format of parameters more gracefully , But in use @NotEmpty、@NotBlank、@NotNull In the process of ,
Because the meaning is a little similar , So there will be some confusion when using , below , Explain the use of these three annotations one by one :
@NotNull
For basic data types (Integer,Long,Double wait ), When @NotNull Annotations are used in String Type of data , Then it means that the data cannot be Null( But it can be for Empty)
@NotBlank
Apply to String Type of data , added @NotBlank The parameter of annotation cannot be Null And trim() after size > 0
@NotEmpty
Apply to String、Collection aggregate 、Map、 Array wait , added @NotEmpty The parameter of annotation cannot be Null perhaps The length is 0
When using these annotations , One more thing to note , That is in Controller When defining methods at layer Add @Valid perhaps @Validated annotation , Otherwise, the annotation will be invalid , Here's the picture :

End of the flower ~
Reference link :https://blog.csdn.net/yangchao1125/article/details/107323177/
边栏推荐
猜你喜欢

RT-Thread 学习笔记(五)---编辑、下载、调试程序

软件测试综述之软件测试的背景、实质、软件开发的过程
![[leetcode daily question 2021/5/8]1723. The shortest time to complete all work](/img/e7/a48bb5b8a86cbc4cd5b37bb16661a8.png)
[leetcode daily question 2021/5/8]1723. The shortest time to complete all work

解决:无法加载文件 C:\Users\user\AppData\Roaming\npm\npx.ps1,因为在此系统上禁止运行脚本 。
![[leetcode daily question 2021/2/14]765. Lovers hold hands](/img/be/8639a05c733638bf0b3fdeb11abccf.png)
[leetcode daily question 2021/2/14]765. Lovers hold hands

RT-Thread 学习笔记(一)---配置RT-Thread开发环境

一文详解Nodejs中fs文件模块与path路径模块
![[paper after dinner] deep mining external perfect data for chestx ray disease screening](/img/d6/41c75d292c26b2e7e116767a51eb5e.png)
[paper after dinner] deep mining external perfect data for chestx ray disease screening

2021-08-12函数递归_和鹏哥学习C语言

用两个栈实现队列
随机推荐
winpcap 抓包函数pcap_loop(),停止问题
面试知识点
flutter 背景变灰效果,如何透明度,灰色蒙板遮罩
剑指Offer(十):矩形覆盖
Pengge C language sixth class
剑指Offer(五十二):正则化表达式
RT-Thread 学习笔记(一)---配置RT-Thread开发环境
Flutter CachedNetworkImage圆角
Add touch screen driver for stemwin 5.22 on Shenzhou IV development board
Sql Server 数据库之数据类型
扫雷pro版2021-08-19
Issue 8: cloud native -- how should college students learn in the workplace
Oracle create index
使用grid实现左中右布局,中间内容自适应
11 handle "self assignment" in operator=
字典与int矩阵
MFC多线程的简单使用
Sword finger offer (53): a string representing a numeric value
C#halcon用户控件崩溃的一种处理方法
Sql Server 之SQL语句对基本表及其中的数据的创建和修改