Got!: -)
I added the following bean instead of the above two in my dispatcher-servlet.xml :
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="/WEB-INF/validationMessages" /> </bean>
Then in my validationMessages.properties I used the following syntax:
NotEmpty.location.title=My custom Message
I think this is the reason: I used Hibernate validation annotations (not javax)
And for the general syntax of the message file should look like
[ConstraintName].[ClassName].[FieldName]=[Message]
Hope this helps some other people ,-)
And to access the message from the spring controller, just add @Autowired private MessageSource messageSource; as a class field and use messageSource.getMessage methods. Since I use only one language, I used messageSource.getMessage( "NotEmpty.location.title", null, null )
dtrunk
source share