示例,验证规则和错误提示作为注解写在声明变量的地方
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
@NotNull private long id; @NotNull @Size (min = 2 , max = 30 ,message= "姓名在2~30个字符之间" ) private String name; @NotNull @Min (message= "年龄至少15岁" ,value= 15 ) private Integer age; @NotEmpty @Email (message= "邮箱格式不对" ) private String email; |
原文:https://www.cnblogs.com/q2546/p/11105023.html