当前位置:网站首页>JSR303数据校验
JSR303数据校验
2022-06-23 13:59:00 【薛定谔妖】
此数据校验的作用很简单,校验客户端发过来的数据是否满足服务端的规则。
比如在Entity类中的一个属性上添加注解@NotBlank
@NotEmpty
private String name;
想要知道@NotEmpty是什么意思,只需要点进去这个注解就好.按住Ctrl,点进去看注释.
就是说被注解的元素必须不是null,而且至少包含一个非空格的元素.
虽然在Entity这个注解标记了校验规则,但是默认是不开启的.如何开启?
如下:
@RequestMapping("/fuck")
public String fuck( @RequestBody @Valid Test1Entity test1Entity){
test1Service.insertData(test1Entity);
return "success";
}
发现除了常规的@RequestMapping注解和@RequestBody注解之外,还存在一个@Valid注解,此@Valid注解表示数据校验在此开启.
当用post请求发送一个Test1Entity对象的时候,后台会自动的校验发送来的name属性是否不是null,并且至少包含一个非空格的元素.
边栏推荐
- Test article
- MATLAB|时序数据中的稀疏辅助信号去噪和模式识别
- 如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup
- Qu'est - ce que ça veut dire? Où dois - je m'inscrire?
- 【深入理解TcaplusDB技术】一键安装Tmonitor后台
- 掌舵9年,艾伦研究所创始CEO光荣退休!他曾预言中国AI将领跑世界
- Thinking and Practice on Quality Standardization (suitable for product, development, testing and management post learning)
- NFNet:NF-ResNet的延伸,不用BN的4096超大batch size训练 | 21年论文
- How to make food nutrition label
- Helm 基础入门 Helm介绍与安装
猜你喜欢

2021-06-07
![[deeply understand tcapulusdb technology] tmonitor module architecture](/img/92/c579ce1e1ce881dd28a2794ffc22f2.png)
[deeply understand tcapulusdb technology] tmonitor module architecture

The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of the TCC mode

MATLAB|时序数据中的稀疏辅助信号去噪和模式识别

Shutter clip clipping component

2021-05-22

2021-05-08

2021-04-15

The well-known face search engine provokes public anger: just one photo will strip you of your pants in a few seconds

Input adjustment of wechat applet
随机推荐
【DataHub】LinkedIn DataHub学习笔记
Assembly language interrupt and external device operation --06
【深入理解TcaplusDB技术】如何实现Tmonitor单机安装
Selenium Edge的IE模式
期货怎么开户安全吗,期货手续费哪家期货公司比较低,适合散户开户?
Pyqt5 designer making tables
Error when Oracle enters sqlplus
[in depth understanding of tcapulusdb technology] how to realize single machine installation of tmonitor
如何解决 Iterative 半监督训练 在 ASR 训练中难以落地的问题丨RTC Dev Meetup
知名人脸搜索引擎惹众怒:仅需一张照片,几秒钟把你扒得底裤不剩
[deeply understand tcapulusdb technology] tmonitor background one click installation
同花顺是股票用的么?现在网上开户安全么?
2022 ICT market in China continues to rise and enterprise digital infrastructure is imperative
Illustration of ONEFLOW's learning rate adjustment strategy
系统设计与分析-技术报告-定时清理验证码的一种解决方案
2021-05-08
Thinking and Practice on Quality Standardization (suitable for product, development, testing and management post learning)
ICML 2022 𞓜 context integrated transformer based auction design neural network
Problems during MySQL uninstallation
Kali use