SpringBlade 基础 entity字段校验不能为空

原文:
https://www.cnblogs.com/felordcn/archive/2020/07/31/13407793.html
http://hibernate.org/validator/documentation/
https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-gettingstarted

entity字段不能为空

需要导入包
import javax.validation.constraints.NotBlank;

在entity的字段上加上这个

@NotBlank(message="名称不能为空")

在controller的方法参数上加上这个
@Valid

其它验证

不能为空:@NotBlank(message="名称不能为空")
最小值为1:@Min(1)

原文地址:https://www.cnblogs.com/guxingy/p/14246344.html