Monday, November 14, 2011

Using message.properties instead of message_en.properties

If you get the following error on using getMessages method:-
.getMessage("check.name", null, locale); 

org.springframework.context.NoSuchMessageException: No message found under code 'check.name' for locale 'en_US'.
org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:135)
    com.tauck.spring.HomeController.home(HomeController.java:41)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:592)

    
   
You need to change the following line in servlet-contxt.xml file

<beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">    
        <beans:property name="basename" value="classpath:com.mycompany.util.messages" />    
</beans:bean>  


to



<beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">    
        <beans:property name="basename" value="com/mycompany/util/messages" />  
</beans:bean>  

No comments:

Post a Comment

Thank you for your feedback