struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Cottenceau ...@mnc.ch>
Subject Re: Character encoding problems after 1.1 to 1.2.4 upgrade
Date Tue, 04 Jan 2005 15:40:07 GMT
"J. Patterson Waltz III" <pattersonw 'at' hotmail.com> writes:

> Hello,
> 
> I recently upgraded a J2EE/Struts web application I'm working on to the
> 1.2.4 version of Struts, and ever since I made this change, I've been
> encountering a problem with the encoding of non-ascii character data
> submitted in forms. All my pages are set to use UTF-8 encoding (via a <%@
> page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"
> language="java" %> directive in my master Tiles layout), and this worked
> fine with Struts 1.1, with respect to data submission and display.  However,
> since I upgraded to 1.2.4, data entered is now stored and redisplayed in its
> "encoded" form rather than its decoded form: i.e. été becomes été

Most probably the browser is sending data in UTF-8 but doesn't
say so with charset= in the Content-Type header. If you're
confident enough that the browsers will send UTF-8 (which should
be the case if they are encoded in UTF-8 and you use
accept-charset in the forms), you can use a filter which forces
the HTTP request to be seen as UTF-8 in input (for example
filters/SetCharacterEncodingFilter which is bundled with
tomcat)[1].

Note: if you also use GET parameters encoded in UTF-8, with tomcat-5 you
have to set `useBodyEncodingForURI="true"' in the Connector or
else tomcat will always consider it ISO-8859-1 (or you can force
the URI to be always decoded as UTF-8, but I think this is more
elegant and versatile that way).


Ref:

[1] this is very surprising, I can't seem to be able to find
stuff in struts archives... for example, searching gmane archives
with google with "struts SetCharacterEncodingFilter
site:gmane.org", I get only one answer; however, I verified that
archives can be accessed on gmane by clicks only (no form post),
so google should crawl them I guess. the search on gmane itself
is extremely slow but gives answers. then, searching
marc.theaimsgroup.com has similar errors with google: 0 answer
from google, however articles are also available by clicks, no
form post needed. and then it's even worse, searching for
SetCharacterEncodingFilter seems to trigger a bug in their search
engine, no answer is shown, only the list of all archives sorted
by month

-- 
Guillaume Cottenceau

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message