注入依赖
注意:SpringBoot2 项目web组件已经内置了这个依赖了
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.1.0.Final</version>
</dependency>
注解 | 说明 |
---|---|
@Null | 注解元素必须为null |
@NotNull | 注解元素必须不为null |
@NotBlank | 注解元素为字符串,并且被trim()以后length要大于0 |
@NotEmpty | 注解元素是否为Null或者Empty |
@AssertTrue | 验证注解元素是否为 true |