You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Néstor Boscán <ne...@gmail.com> on 2012/01/06 05:17:51 UTC
Default Encoding not working in struts2-json plugin
Hi
I'm using Struts 2 2.1.8.1 with the Struts 2 JSON plugin. I'm using
accented characters and event if I configure the defaultEncoding to
ISO-8859-1 the resulting JSON document is sent using UTF-8. In IE it
gives a data error because the page encoding ISO-8859-1 is not the
same as the JSON document. Has this been corrected in newer versions?.
Any ideas?
Regards,
Néstor Boscán
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Default Encoding not working in struts2-json plugin
Posted by he...@gmail.com.
It is not a good idea that data don't travel in UTF-8. For example you couldn't use jquery neither struts2-jquery plugin...
-----Original Message-----
From: Néstor Boscán <ne...@tcs.com.ve>
Date: Fri, 6 Jan 2012 09:07:53
To: Struts Users Mailing List<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Re: Default Encoding not working in struts2-json plugin
Found it
I think it was the Apache Server that was converting the JSON
documents to UTF-8.
Regards,
Néstor Boscán
On Fri, Jan 6, 2012 at 8:33 AM, Hernán <he...@gmail.com> wrote:
> Nestor: first of all, verify that your database has the correct encoding,
> it should be ISO-8859-1, then what I can tell you is that is better that
> data travels in UTF-8 format, because that's the way it was meant to be...
> So what's next? If you're working with JSP add this to the beginning of
> each .jsp:
> <%@ page language="java" contentType="text/html;charset=UTF-8"
> pageEncoding="ISO-8859-1" %>
>
> As you can see, you have now your database and JSP in ISO-8859-1, whilst
> the data is traveling in the format it should travel, that is to say:
> UTF-8... When using a form with file upload capabilities, just use this
> attribute in it:
>
> enctype="multipart/form-data; charset=UTF-8"
>
> This way you are ensuring data is traveling in UTF-8.
>
> If you're using a different view technology as freemarker or velocity, you
> should look for the analog <%@ page ... of it...
>
> I hope this helps you!
>
>
>
> 2012/1/6 Néstor Boscán <ne...@gmail.com>
>
>> Hi
>>
>> I'm using Struts 2 2.1.8.1 with the Struts 2 JSON plugin. I'm using
>> accented characters and event if I configure the defaultEncoding to
>> ISO-8859-1 the resulting JSON document is sent using UTF-8. In IE it
>> gives a data error because the page encoding ISO-8859-1 is not the
>> same as the JSON document. Has this been corrected in newer versions?.
>> Any ideas?
>>
>> Regards,
>>
>> Néstor Boscán
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> --
> Hernán
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Default Encoding not working in struts2-json plugin
Posted by Néstor Boscán <ne...@tcs.com.ve>.
Found it
I think it was the Apache Server that was converting the JSON
documents to UTF-8.
Regards,
Néstor Boscán
On Fri, Jan 6, 2012 at 8:33 AM, Hernán <he...@gmail.com> wrote:
> Nestor: first of all, verify that your database has the correct encoding,
> it should be ISO-8859-1, then what I can tell you is that is better that
> data travels in UTF-8 format, because that's the way it was meant to be...
> So what's next? If you're working with JSP add this to the beginning of
> each .jsp:
> <%@ page language="java" contentType="text/html;charset=UTF-8"
> pageEncoding="ISO-8859-1" %>
>
> As you can see, you have now your database and JSP in ISO-8859-1, whilst
> the data is traveling in the format it should travel, that is to say:
> UTF-8... When using a form with file upload capabilities, just use this
> attribute in it:
>
> enctype="multipart/form-data; charset=UTF-8"
>
> This way you are ensuring data is traveling in UTF-8.
>
> If you're using a different view technology as freemarker or velocity, you
> should look for the analog <%@ page ... of it...
>
> I hope this helps you!
>
>
>
> 2012/1/6 Néstor Boscán <ne...@gmail.com>
>
>> Hi
>>
>> I'm using Struts 2 2.1.8.1 with the Struts 2 JSON plugin. I'm using
>> accented characters and event if I configure the defaultEncoding to
>> ISO-8859-1 the resulting JSON document is sent using UTF-8. In IE it
>> gives a data error because the page encoding ISO-8859-1 is not the
>> same as the JSON document. Has this been corrected in newer versions?.
>> Any ideas?
>>
>> Regards,
>>
>> Néstor Boscán
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> --
> Hernán
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Default Encoding not working in struts2-json plugin
Posted by Hernán <he...@gmail.com>.
Nestor: first of all, verify that your database has the correct encoding,
it should be ISO-8859-1, then what I can tell you is that is better that
data travels in UTF-8 format, because that's the way it was meant to be...
So what's next? If you're working with JSP add this to the beginning of
each .jsp:
<%@ page language="java" contentType="text/html;charset=UTF-8"
pageEncoding="ISO-8859-1" %>
As you can see, you have now your database and JSP in ISO-8859-1, whilst
the data is traveling in the format it should travel, that is to say:
UTF-8... When using a form with file upload capabilities, just use this
attribute in it:
enctype="multipart/form-data; charset=UTF-8"
This way you are ensuring data is traveling in UTF-8.
If you're using a different view technology as freemarker or velocity, you
should look for the analog <%@ page ... of it...
I hope this helps you!
2012/1/6 Néstor Boscán <ne...@gmail.com>
> Hi
>
> I'm using Struts 2 2.1.8.1 with the Struts 2 JSON plugin. I'm using
> accented characters and event if I configure the defaultEncoding to
> ISO-8859-1 the resulting JSON document is sent using UTF-8. In IE it
> gives a data error because the page encoding ISO-8859-1 is not the
> same as the JSON document. Has this been corrected in newer versions?.
> Any ideas?
>
> Regards,
>
> Néstor Boscán
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Hernán