Announcement Announcement Module
Collapse
No announcement yet.
ReloadableResourceBundleMessageSource encoding problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ReloadableResourceBundleMessageSource encoding problem

    Hi!

    When trying to read a string containing non-english chars from a property file using getMessage() in ReloadableResourceBundleMessageSource, an encoding problem seems to occur.

    The property file messages.properties is encoded using ISO-8859-1 and contains

    Code:
    footer.message.eventsFound={0} körningar funna
    In my SimpleFormController, I use the following code to get the message from the property file:

    Code:
    ReloadableResourceBundleMessageSource msgSrc = new ReloadableResourceBundleMessageSource();
    msgSrc.setDefaultEncoding("ISO-8859-1");
    msgSrc.setBasename("messages");
    
    ...
    
    String s = msgSrc.getMessage(
    	"footer.message.eventsFound", 
    	new Object[]{new Integer(eventList.size())},  
    	request.getLocale()
    )
    The result from getMessage() is "11 körningar funna"

    Note that this encoding problem only occurs when trying to access the property file from the Controller code! When accessing it directly from the JSP, using

    Code:
    <spring:message code="footer.message.eventsFound"/>
    it all looks fine! How come I get encoding problems in the Controller but not in the JSP?

    I've tried to use a simple ResourceBundleMessageSource as well, but with the same, disappointing result!

    Has anyone run into a similar problem? All tips are really appreciated!

    Thanks!

    Regards,
    Jacob
Working...
X