Tag: spring modules

基于注释的Spring beanvalidation

我正在研究一种基于注释的方法来使用spring模块validationSpring bean。 在本教程中 ,以下bean(省略了getters和setter)用作示例: public final class User { @NotBlank @Length(max = 80) private String name; @NotBlank @Email @Length(max = 80) private String email; @NotBlank @Length(max = 4000) private String text; } 如果违反特定validation规则,则使用的错误消息应遵循以下格式: bean-class.bean-propery[validation-rule]=Validation Error message 上面显示的类的示例包括: User.email[not.blank]=Please enter your e-mail address. User.email[email]=Please enter a valid e-mail address. User.email[length]=Please enter no more than {2} characters. […]