YoannM
Mar 12th, 2008, 11:50 AM
Hi everybody,
I might be blind or something but I couldn't find anything on the Spring forum to deal with the UTF-8 problem inside the internationalization i18n property files.
I found a good solution, so I am posting it here for those who, like me, don't find anything about it.
The secret is here to use the "ReloadableResourceBundleMessageSource" instead of the "ResourceBundleMessageSource" and then forcing it to read the UTF-8 encoding.
<bean id="messageSource" class="org.springframework.context.support.ReloadableReso urceBundleMessageSource">
<property name="basename" value="WEB-INF/classes/messages" />
<property name="fileEncodings" value="UTF-8" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
However, beware of the value of basename !! With the "ResourceBundleMessageSource" it would be something like value="messages" but with the "ReloadableResourceBundleMessageSource" it has to be the 'full path' from the WEB-INF directory.
I believe that is a good solution, but if somebody else knows something better, please let me know.
Cheers,
Yoann
I might be blind or something but I couldn't find anything on the Spring forum to deal with the UTF-8 problem inside the internationalization i18n property files.
I found a good solution, so I am posting it here for those who, like me, don't find anything about it.
The secret is here to use the "ReloadableResourceBundleMessageSource" instead of the "ResourceBundleMessageSource" and then forcing it to read the UTF-8 encoding.
<bean id="messageSource" class="org.springframework.context.support.ReloadableReso urceBundleMessageSource">
<property name="basename" value="WEB-INF/classes/messages" />
<property name="fileEncodings" value="UTF-8" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
However, beware of the value of basename !! With the "ResourceBundleMessageSource" it would be something like value="messages" but with the "ReloadableResourceBundleMessageSource" it has to be the 'full path' from the WEB-INF directory.
I believe that is a good solution, but if somebody else knows something better, please let me know.
Cheers,
Yoann