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>  

		
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s