• Post Reply Bookmark Topic Watch Topic
  • New Topic

which beanValidator should be used with constrain validation  RSS feed

 
sam White
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

With spring mvc 3.0, I am confused about using BeanValidator with constrain validation.:



The beanValidator as shown above is confusing me, I can't find an import lib to use.
This example is referenced with an example in the following link:

http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303


Any suggestion is very appreciated.
Thanks
Sam
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
beanValidator is just the name he chose not the type. Validator is defined in javax.validation.Validator. You would use the factory to get an instance



Some containers will provide their own implementations of Validator which may or may not cause you problems if you wanted to force it to use the Hibernate validator implementation for example you could do something like this



Keep in mind the Validator is NOT thread safe. Validator Factories are.
 
sam White
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the solution, that works.
Do you know how to display the error message on jsp?

At the moment, when error occurs, the page returns to the page, but no error message shown up on the page.

Here is my jsp file:



Controller:



And... With the above controller code, how to combine the "general" binding result wiht the one shown in Violation into one?
Thanks
Sam
 
honey free
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep in mind the Validator is NOT thread safe. Validator Factories are.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!