I have a problem with JSR303 and in special Hibernate-Validator.
I want to read a validation message from a property file. This property file lives in the war file that is deployed to the servlet container. The problem is, it's not accessed. I have the following project structure.
How can I access both ValidationMessages.properties? Or is this impossible?
Beyond that it would be perfect if the Hibernate-Validator first would read the property file in the war and if it wouldn't find the key, then read the property file from the jar and so on.
It's not possible to have more than one ValidationMessages.properties
file. But you could use Hibernate Validators AggregateResourceBundleLocator to retrieve messages from bundles with different names like this:
ValidatorFactory validatorFactory = configuration
.messageInterpolator(
new ResourceBundleMessageInterpolator(
new AggregateResourceBundleLocator(
Arrays.asList("foo", "bar"),
configuration.getDefaultResourceBundleLocator())))
.buildDefaultValidatorFactory();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With