Very new to spring and working my way through validation.
I have examples working where I actually implement the spring Validator class, but am working on getting examples working without implementing the Validator class and instead using annotations directly on model class attributes such as @NotBlank and @Email.
M开发者_JAVA技巧y question is this. Is there anyway to make the above scenario (annotations directly on class attributes) work where you are not naming your Controllers after the models that they are implementing?
For example if I had a FormController class and one of the functions inside dealt with adding a user. Is there anyway to Autowire the validation for the User class directly to the Annotations on the the User class or am I stuck writing a UserValidator class and using that.
Have a look at Spring-Roo. I believe they do what you are asking for.
精彩评论