Sending spanish characters in form submission

Tag: character-encoding , portlet , websphere-portal , jsr286 , spring-portlet-mvc Author: z657558651 Date: 2013-05-17

I'm building Portlets using Spring Portlet MVC 3.02 and deploying them on WebSphere Portal V7. I have a form submission where one combo box requires to sent an Spanish character. Something like this:

<form:select id="${ns}imTheField" path="imTheField" cssStyle="width:120px;">
    <option value="AtTheEndTheresASpanishCharacterÑ">
        AtTheEndTheresASpanishCharacterÑ
    </option>                                                   
</form:select>

The "Ñ" character looks nice in the Screen. That combo value maps to the command attribute imTheField by Spring Binding process. After form submission and in the handler method, this is what I get when I log that command attribute:

theCommand.getImTheField: AtTheEndTheresASpanishCharacterÃ

Which is not the character that came from the form. This is getting me trouble as when there are errors in form submission I have to show the form again with the previous values, which now I don't have because of that issue.

Any ideas? This is what I get from Chrome debugging at form submission:

Request Headers
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:es

Form Data
imTheField:AtTheEndTheresASpanishCharacterÑ

Response Headers
Content-Language:es
Content-Type:text/html; charset=UTF-8

Note that the field imTheField looks nicely formatted. Maybe is an issue with the Accept-Charset request header?

Other Answer1

see: http://floatingcube.blogspot.co.uk/2008/10/special-characters-in-spring-mvc.html

You may need to use a filter as spring is using ISO-8859-1 rather than UTF-8

comments:

It's a Portlet application, I don't think Servlet filters apply
A portlet application is just a variation on a dynamic web application. You can still use filters. For example authentication filters are often used in Websphere Portal for attaching to login and logout events
Already try it. Doesn't fix the issue
ur jsp contains smth like <[email protected] language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>? if this not helps try implement Action Filter same way as encoding filter above, sources is available on springsource or github