I have implemented a bean with hibernate and hibernate validation. This is the field I am testing on.
@NotBlank(message ="test.test" )
private String test;
I have a file
messages.properties
and
messages_en.properties
that I use. Spring.message tags work so the files can be found and are used in the system elsewhere. I get "test.test" as my validation error when I try to store an object with that field empty and not error message in messages.properties. What am I missing?
The problem was that i was missing this in my configuration. Also message="{test.test}" was necessary.
<mvc:annotation-driven validator="validator" />
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="messageInterpolator">
<bean class="org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator">
<constructor-arg index="0">
<bean
class="org.springframework.validation.beanvalidation.MessageSourceResourceBundleLocator">
<constructor-arg index="0" ref="messageSource" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>