UTF-8 encoding in Spring MVC, problem with FORMs

jbb picture jbb · Feb 28, 2011 · Viewed 41k times · Source

I have this in web.xml

   <filter>
        <filter-name>encoding-filter</filter-name>
        <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </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>

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

and at the top of file.jsp I have this:

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

in <head> this:

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

and characters other than latin-1 set from FORM with method POST are still not correct.

Answer

jbb picture jbb · Feb 28, 2011

I solved this.

That filter in web.xml must be first filter in file.