其他分享
首页 > 其他分享> > JSR303数据校验

JSR303数据校验

作者:互联网

1.导入依赖

<dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <version>2.0.2</version>
        </dependency>

 

2.给要校验的javaBean上标注校验注解

@Validated
public class Dog
给对象属性添加校验注解
@Email(message = "邮箱格式错误")
private String name;

 

标签:JSR303,校验,private,jakarta,注解,message,validation,数据
来源: https://www.cnblogs.com/upupup-999/p/15769114.html