Results 1 to 2 of 2

Thread: UTF-8 Enconding doesn't work

  1. #1
    Join Date
    Jan 2008
    Posts
    1

    Default UTF-8 Enconding doesn't work

    Hi all!

    I have an Issue that I need to display russian characters and searched for it in the internet, how to solve it with spring.

    What I did until now is:

    1.
    Adding the parameters:

    URIEncoding="UTF-8" useBodyEncodingForURI="true"

    to my Server.xml of my tomcat 5.

    2.

    adding a filter to my web.xml

    <filter>
    <filter-name>CharacterEncodingFilter</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>
    </filter>

    <filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    3.

    Adding the contentType property in my application-servlet.xml

    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="prefix">
    <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    <property name="viewClass">
    <value>org.springframework.web.servlet.view.JstlVi ew</value>
    </property>
    <property name="contentType">
    <value>text/html;charset=UTF-8</value>
    </property>
    </bean>

    4 Also adding the following lines in my Jsp:

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

    <%@ page language="java" contentType="text/html; charset=UTF-8" %>


    If I now for example write the russian word: "Наименование" in my Jsp, It will display in the Browser: Ðаименование

    Does anybody know what I forgot to configure?

    Thanks a lot!

    Best regards,
    Dennis

  2. #2
    Join Date
    Oct 2006
    Posts
    228

    Default

    Hi,

    I got character encoding working correctly in the past. The instructions are available at http://forum.springframework.org/sho...6&postcount=14. The only thing I can see that might be a problem is if your character encoding filter is not the first in the filter chain. If there are other filters which read the request before the character encoding is performed then the default encoding will be used and the value set by the filter is ignored.

    Hope this helps,

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •