struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carl ballantyne <carl.ballant...@cast-info.es>
Subject Re: struts.i18n.encoding
Date Fri, 20 Nov 2009 10:51:56 GMT
Hi Cristian,

Thanks very much for your response.

I am using GlassFish 2.1 so will have a look to see if I can implement  
your type of solution. What I don't get is why we need to apply a  
filter when already the server is configured to use UTF-8 and we have  
UTF-8 defined in the meta for the JSP.

It just seems strange that nobody has got this to work with  
struts.i18.encoding. Surely there must be some other people out there  
with multi language struts 2 apps.

I will try your solution and keep digging some more.
Cheers,
Carl.

Quoting Cristian Peraferrer <corellian.c@gmail.com>:

> In my application also used the 'struts.i18.encoding=UTF-8' but I had
> the same problem. But I found a way to get it to work.
> This way you are only telling struts that has to use UTF-8. But you
> also need to tell to your Applications Container
> (Tomcat for example) that you want UTF-8.
>
> 1. Set the URI encoding of Tomcat's server.xml configuration file. Set
> URIEncoding="UTF-8" in your http/https connectors:
>
> <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
>     <Connector URIEncoding="UTF-8" acceptCount="100"   
> connectionTimeout="20000"
>                disableUploadTimeout="true" enableLookups="false"
>                maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150"
>                minSpareThreads="25" port="80" redirectPort="443"/>
>
> 2. Set a custom filter to configure POST requests use UTF-8:
>
> <!-- To get POST requests as UTF-8 -->
> <filter>
>   <filter-name>encodingFilter</filter-name>
>   <filter-class>path.to.your.filter.SetCharacterEncodingFilter</filter-class>
>   <init-param>
>     <param-name>encoding</param-name>
>     <param-value>UTF-8</param-value>
>   </init-param>
> </filter>
>   <filter-mapping>
>     <filter-name>encodingFilter</filter-name>
>     <url-pattern>/*</url-pattern>
>   </filter-mapping>
>
> Tomcat already comes with such an example filter of   
> SetCharacterEncodingFilter.
>
> 3. Also in my application's web.xml I have set that JSPs use UTF-8   
> as a default:
>
> <jsp-config>
>   <!-- UTF-8 as the default JSP encoding -->
>   <jsp-property-group>
>     <url-pattern>*.jsp</url-pattern>
>     <page-encoding>UTF-8</page-encoding>
>   </jsp-property-group>
> </jsp-config>
>
> 4. In every JSP you I have the following typical <meta> tag inside <head>:
>
>   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>
> I hope it will help.
>
> Cristian.
>
>
> On Fri, Nov 20, 2009 at 10:14 AM, carl ballantyne
> <carl.ballantyne@cast-info.es> wrote:
>> Hi Guys,
>>
>> I have an app with form fields and when submitting them to my Struts 2
>> actions the values are getting garbled. For example "espaƱa" becomes
>> "espa?".
>>
>> I think the problem is with Struts because when I create a basic jsp page
>> and submit back to itself and display the form field - it works fine.
>>
>> I have tried setting struts.i18n.encoding=UTF-8 in the struts.properties
>> file and the struts.xml file to no avail. Has anyone used this with success?
>> I have searched the forums and it seems to me that people have to resort to
>> custom filters to workaround the problem.
>>
>> Cheers,
>> Carl.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
>
> --
> GPG Key-ID: 0x564903FA - JID: corellian@swissjabber.ch
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>




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


Mime
View raw message