SpringMVC 的 Validation 校验
1、maven配置文件引入架包: <!-- SpringMVC --> <dependency> ... </dependency> <!-- SpringMVC中用到了Hibernate的Validator包 --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.3.Final</version> </dependency> 2、常用Bean对象的注释 @NotBlank 不为空或空字符串 @NotNull 不为空 @Size(min, max) 字符串长度 @Email 邮箱格式 @Pattern(regexp) 正则表达式匹配 注释用法: public class LoginParam { private String user; private String password; @NotBlank(message = "用户不能为空") @Size(min = 5, max = 20, message = "用户长度范围为5-20个字符") public String getUser() { return user; } public void setUser(String user) { this.user =