Validator源码分析

master
xuchengsheng 2023-12-04 16:53:25 +08:00
parent 4bdc81ba69
commit a231cb2146
1 changed files with 7 additions and 0 deletions

View File

@ -204,6 +204,13 @@ public class Person {
}
```
运行结果发现, `PersonValidator` 正确地根据定义的验证规则识别出了 `Person` 对象的不合规数据,并通过 `Errors` 对象生成了相应的错误消息。
```
name:姓名不能为空
age:目前年龄最大的是120岁
```
### 八、与其他组件的关系
+ **Spring MVC框架**