Hi there,
I am using Spring 3 MVC and I have setup a form to capture input from a user. This form includes a textarea for a description String in my model object, Event. My corresponding controller looks like this:
@RequestMapping(value = "/admin/event/{eventId}/edit", method = RequestMethod.POST)
public String updateEvent(@ModelAttribute Event event) {
logger.info("updateEvent(): Event description: " + event.getDescription());
return "redirect:/admin/event/" + event.getId() + "/edit";
}
Whenever I enter a '€' character into the form's description field and POST the form, the logged description has a '?' instead of a '€'.
I am using a CharacterEncodingFilter in front of my DispatcherServlet but this has not resolved the problem. For reference, my web.xml looks like this:
<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>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>baseApp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>baseApp</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Any thoughts on how to properly capture the € character?
Update:
I've asked a similar question previously involving MySQL, but as you can see from the demonstration above, the € is transformed to a ? with no MySQL involvement at all, i.e. between POST'ing the form and logging the event's description. This is why I've asked the question again.. it seems this problem is isolated to Spring.