Use following in JSP page.
You should get with all default properties.
By default in tomcat it is ISO-8859-1
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>

In worst case test some thing like this in your action file.

  String strTemp=new String(strProperty.getBytes("ISO-8859-1"), "UTF-8");

-----Original Message-----
From: carl ballantyne [mailto:carl.ballant...@cast-info.es] 
Sent: Friday, November 20, 2009 4:22 PM
To: user@struts.apache.org
Subject: Re: struts.i18n.encoding

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 <corellia...@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.ballant...@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-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
>
>
> --
> GPG Key-ID: 0x564903FA - JID: corell...@swissjabber.ch
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>






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

Reply via email to