Search code examples
springjstltilesresourcebundle

Multiple ResourceBundles with Spring and JSTL


Here's my problem: I want to organize my resource bundle files so that I have the messages in one file and the labels in another. For this I created two .properties files which I declared in my spring configuration files. The actual declaration is this:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <array>
            <value>strings.gui</value>
            <value>strings.messages</value>
        </array>
    </property>
</bean>

The folder layout goes like this:

/WEB-INF/classes/ro/** - source files

/WEB-INF/classes/strings/* - i18n files (gui_ro.properties and messages_ro.properties, along with their _en versions)

Everything works great when I display labels from gui_xx.properties but it fails to display messages from messages_xx.properties files. The error message in the server console is

ResourceBundle [strings.messages] not found for MessageSource: Can't find bundle for base name strings.messages, locale ro

I'm using JSTL with TilesView, and the problem occurs regardless of what tag I use to display the text - fmt:message key=... or spring:message code=....

Can anybody help pe with this?

Thank you very much and have a good day.


Solution

  • I think the correct basenames should be:

        <value>classpath:/ro/gui</value>
        <value>classpath:/strings/messages</value>
    

    Can you please try these values for basenames.