Announcement Announcement Module
Collapse
No announcement yet.
unicode display problem using Spring MVC with freemarker Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • unicode display problem using Spring MVC with freemarker

    hey guys,

    I am trying to display some nepali langauage charcaters in my spring MVC webapp with freemarker, I am trying to read the message from messages.properties file using <@spring.message code='error.input'/> tag.

    i did everything, like i have character encoding filter in my web.xml

    <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEnco dingFilter</filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
    <param-name>forceEncoding</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>

    My freemarker configuration is like

    <bean id="viewResolver" class="org.springframework.web.servlet.view.freema rker.FreeMarkerViewResolver">
    <property name="cache" value="true"/>
    <property name="prefix" value=""/>
    <property name="contentType" value="text/html; charset=UTF-8"/>
    <property name="suffix" value=".ftl"/>
    <property name="exposeSpringMacroHelpers" value="true"/>
    </bean>

    and in template i have

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    defined i just see some weird charcaters in my page. Though the response header has the
    correct content type "text/html; charset=UTF-8"

    Not sure what and where's the problem. I even tried to set the content type from the
    controller response.setContentType('text/html; charset=UTF-8");

    Help guys

  • #2
    ok i fixed this issue, i used ReloadableResourceBundleMessageSource instead of ResourceBundleMessageSource with property defaultEncoding to UTF-8 so
    also had to add classpath for basename property value.

    <bean id="messageSource" class="org.springframework.context.support.Reloada bleResourceBundleMessageSource">
    <property name="basename" value="classpath:messages"/>
    <property name="defaultEncoding" value="UTF-8"/>
    <property name="useCodeAsDefaultMessage" value="false"/>
    </bean>

    it works now..

    Comment

    Working...
    X