| Author |
which beanValidator should be used with constrain validation
|
sam White
Ranch Hand
Joined: Feb 18, 2011
Posts: 204
|
|
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
Joined: Mar 07, 2010
Posts: 1282
|
|
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.
|
[How To Ask Questions][Read before you PM me]
|
 |
sam White
Ranch Hand
Joined: Feb 18, 2011
Posts: 204
|
|
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
Joined: Dec 17, 2012
Posts: 1
|
|
|
Keep in mind the Validator is NOT thread safe. Validator Factories are.
|
"honey"
|
 |
 |
|
|
subject: which beanValidator should be used with constrain validation
|
|
|