Announcement Announcement Module
Collapse
No announcement yet.
Loading localized error messages through Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading localized error messages through Spring

    Hi All,

    I am using Spring framework in the business layer of my web services project. Apart from basic DI, I am using it to load localized error messages (french, Korean, chinese etc). The error messages are transmitted as SOAP fault. Everything works fine, I am able to get localized error messages for European countries (french, spanish etc.), however, I am getting some weird characters for korean, chinese etc. messages. The error messages are stored in errorMessages_xx.properties files in a particular location. It seems, the properties files are loaded properly, but the message is coming with the weird characters. For an instance, I have a message as shown below (for Korean locale):
    =고객 보고 증상 및 Sold-To 진단 필드는 필수입니다.

    When I get SOAP-Fault, it is coming like:

    *객 보* 증ƒ 및 Sold-To „‹ •„“œŠ” •„

    Any specific reason? Should I do any configurations in my Spring config. My Spring config is like:

    Code:
    <bean id="errorMessages" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basenames">
                <list>
                    <value>file:${server.home}/abc-config/app/messages/errorMessages</value>
                </list>
            </property>
            <property name="cacheSeconds" value="1" />
        </bean>
    This is an urgent issue. Please provide some hints/solution if anyone has faced this kind of problem.

    Thanks and Regards,
    Niranjan

  • #2
    Hi All,

    I have found a solution to this. I don't know if this is the correct one. Please validate and let me know.

    I modified the bean configuration for MessageSource as shown below:
    Code:
    <bean id="errorMessages" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basenames">
                <list>
                    <value>file:${server.home}/gsx-config/app/messages/errorMessages</value>
                </list>
            </property>
            <property name="cacheSeconds" value="1" />
            <property name="defaultEncoding" value="UTF-8" />
            <property name="fileEncodings" value="UTF-8" />
        </bean>
    Now Spring is able to load the UTF-8 encoded characters.

    Thanks and Regards,
    Niranjan

    Comment

    Working...
    X