Looking for software experts?
Need an expert advice on software development? Need consulting work done in time and at high standards? Tremend has the right solution for you.

We can provide expertise in:
  •    » high traffic and complex content website infrastructures using Java, PHP or .NET. More here ...
  •    » mobile applications for iPhone, Android or J2ME. More here ...

For an enquiry, send an email to contact [at] tremend [dot] ro.

End to end UTF-8 encoding usage with MySql and Spring – Part 2

September 1st, 2006 by Ioan Cocan in Java, General

One thing I forgot to mention was the usage of Spring message bundles. Usually, a ResourceBundleMessageSource is configured to inject bundle messages for Spring MVC. The only bad thing is that I could not specify an encoding for the configured message.properties files. As the default properties format is ISO 8859-1 character encoding and tedious operations like transformation of Unicode characters using native2ascii tool is necessary, I looked for a way to load UTF-8 resource files without any transformations. Spring has a ReloadableResourceBundleMessageSource class that allows just that, along with the reloadable behaviour. The bundle configuration now looks:

<bean id=”messageSource” class=”org.springframework.context.support.ReloadableResourceBundleMessageSource”>

<property name=”basename”>

<value>/WEB-INF/classes/messages</value>

</property>

<property name=”defaultEncoding”>

<value>UTF-8</value>

</property>

<property name=”cacheSeconds”>

<value>-1</value>

</property>

</bean>

DZoneGoogle ReaderYahoo MessengerRedditEmailDelicious

Related posts

  • End to end UTF-8 encoding usage with MySql and Spring
    Setting up a solution to store, manage and display UTF-8 data using MySql was quite a challenge.There are some a few steps that you have to get right, otherwise garbage data will come out at various stages...
  • My experience with web services with Spring, Axis, XFire
    First thing to note is that, this being my first contact with web services (SOAP and WSDL), it took me quite a lot of time (almost five working days) to learn about the technologies involved and try to...
  • Hibernate annotations – default value
    If you wanted to set the default value using hibernate annotations, you've probably had some difficulties, as it was the case for me. Some posts on the web talk about default values to the members of the...
  • MySql, PHP and UTF8
    Nowadays UTF8 is far from being just "trendy", it’s the de facto standard for information representation. There are a lot of discussions on the "why locales are bad" theme, and I’m not going to argue...
  • Spring+JPA with MySQL/Oracle configurations
    During development for a solution based on Spring+JPA+MySQL/Oracle we came across two settings to watch for. 1. Database isolation level The default isolation level in MySQL is REPEATABLE READ,...
.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.