I'm hoping one of you brilliant Spring developers will be able to help me with this. I've been stuck all day, researching docs and online tips, to no avail.
Want to support i18n internationalization in a simple test Spring MVC web app using the messages in a JSP.
My message_xx_YY.properties files are in /src/main/webapp/resources/international/. I currently have messages_en_US.properties and messages_es_ES.properties.
I've tried every combination of messageSource basename I can think of in my servlet-context.xml file, and I always get the error "nested exception is java.util.MissingResourceException: Can't find bundle for base name messages, locale en_US".
Here's my ../WEB-INF/spring/appServlet/servlet-context.xml file:
I've tried all of the following:Code:<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /> <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <!-- Support i18n message bundles --> <beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <!-- This is the path to where the property file is located, plus base name of the properties file (messages, ex: the bean will expand to messages_en_US.properties) --> <beans:property name="basename" value="classpath:/resources/international/messages" /> <beans:property name="cacheSeconds" value="1" /> <beans:property name="defaultEncoding" value="UTF-8" /> <beans:property name="fallbackToSystemLocale" value="true" /> </beans:bean> <context:component-scan base-package="com.mydomain.myapp" /> </beans:beans>
and have even tried moving the properties files to WEB-INF with appropriate basename - no change.Code:<beans:property name="basename" value="classpath:/resources/international/messages" /> <beans:property name="basename" value="/resources/international/messages" /> <beans:property name="basename" value="resources/international/messages" /> <beans:property name="basename" value="./resources/international/messages" /> <beans:property name="basename" value="../resources/international/messages" />
My NavigationController, which I don't beleive is the issue, is:
Does anyone have any idea what I'm doing wrong here? Greatly appreciate ANY help, guidance, or assistance.Code:Locale locale = Locale.getDefault(); ResourceBundle resources = ResourceBundle.getBundle("messages", locale);
Thanks!


Reply With Quote
