Announcement Announcement Module
No announcement yet.
unicode display problem using Spring MVC with freemarker Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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 file using <@spring.message code='error.input'/> tag.

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

    <filter-class>org.springframework.web.filter.CharacterEnco dingFilter</filter-class>

    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"/>

    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=" bleResourceBundleMessageSource">
    <property name="basename" value="classpath:messages"/>
    <property name="defaultEncoding" value="UTF-8"/>
    <property name="useCodeAsDefaultMessage" value="false"/>

    it works now..