This problem actually came from HDIV framework version 2.1.2. A patch is available here if you can't use the next release.
Hope it will help someone.
Question
I have a problem with my UTF-8 encoding. My webapp uses french words that are correctly displayed in my jsp, but not in my controller after a POST. For example, in my jsp I have:
Prénom de mon père
and when I post the form, the controller gets:
Prénom de mon père
The characterEncodingFilter is the first filter in the file as described in this post
Here is my jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!doctype html>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="content-language" content="fr">
...
</head>
<form:form class="form-horizontal" modelAttribute="AlimentationForm"
action="${actionUrl}" method="POST">
...
<form:input path="questions" class='input-xlarge' type='text' value='Prénom de mon père'/>
</form>
My web.xml:
<filter>
<filter-name>characterEncodingFilter</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>characterEncodingFilter</filter-name>
<url-pattern>/web/*</url-pattern>
</filter-mapping>
And my application-config.xml
<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename">
<beans:value>classpath:messages</beans:value>
</beans:property>
<beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>
I don't know what's wrong in my app or my configuration, have you got any idea?
Thank in advance.
EDIT: I'm using HDIV framework
Solution
This problem actually came from HDIV framework version 2.1.2. A patch is available here if you can't use the next release.
Hope it will help someone.
OTHER TIPS
Make sure the JSP page encodes the data sent to the server properly. Try adding
<%@page pageEncoding="UTF-8" %>
to the top of your JSP as this ensures any data sent along http will get encoding correctly.
I believe the default http encoding is ISO-8859-1.