title: Encoding problem using Spring MVC
body: <p>I have a demo web application that creates users. When I try to insert data in other languages (like french) the characters are not encoded correctly.  The code on the controller is:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
      @RequestMapping(value = "/user/create.htm", params={"id"}, method = RequestMethod.GET)
      public String edit(@RequestParam("id") Long id, ModelMap model) {
          System.out.println("id is " + id);
          User user = userService.get(id);
  
          model.put("user", user);
          return "user/create";
      }
  
      @RequestMapping(value = "/user/create.htm", method = RequestMethod.POST)
      public String save(@ModelAttribute("user") User user, BindingResult result) {
  
          System.out.println(user.getFirstName());
          System.out.println(user.getLastName());
  
  
          validator.validate(user, result);
          if(result.hasErrors()) {
              return "user/create"; 
          }
  
          userService.save(user);
          return "redirect:list.htm";
      }
  </code></pre>
  
  <p>my web.xml is:</p>
  
  <pre><code>...
  
      &lt;filter&gt;
          &lt;filter-name&gt;encoding-filter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;encoding&lt;/param-name&gt;
              &lt;param-value&gt;UTF-8&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;encoding-filter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
  ...
  </code></pre>
  
  <p>and the page is:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  
  ...
  
  &lt;form:form method="post" commandName="user"&gt;
  
  ...
  
  &lt;form:input path="firstName" cssErrorClass="form-error-field"/&gt;
  
  ...
  </code></pre>
  
  <p>when I enter some french characters in the first name then the output from the <code>system.out.println</code> is <code>????+?????</code> or something similar.</p>
  
  <p>I saw other people fixing this with the <code>CharacterEncodingFilter</code> but this doesn't seem to work.</p>
  
  <p>Thanks a lot.</p>
  
  <p>Edited the filter value.</p>