1

I have an application in Java EE and I have my database in ISO-8859-1, thus I need do the jsp encoding in ISO-8859-1... (all my pages are in iso-8859-1)

I have a jsp with a javascript code, which does a request to a Struts action.

This is my js code.

$.ajax({
    type:'GET',
    encoding:'iso-8859-1',      
    contentType: 'text/html;charset=ISO-8859-1',
    url: xUrl,
    success: function(){
        $("#MensajeOk").attr('style','display:block');
        $("#MensajeOk").delay(10000).slideUp(1000);
    }
});

with IE and Chrome all is correct, because it does the request coding in ISO-8859-1 but Firefox encodes the request in UTF-8 and this is a problem for me, because in server side I need ISO-8859-1 and with FF there are some characters than i can't recover.

mi form is

<html:form action="/action.do" acceptCharset="iso-8859-1"> 
<input type="text" name="title">

and my java code is

new String((request.getParameter("title")+"").getBytes("iso-8859-1"),"iso-8859-1"));

with it, I can recover fine the text with IE and Chome, but fails with Firefox.

Other option will be send the request in UTF-8 encoding by encodeURI('data') but in the server side I can't convert the text from UTF-8 to ISO-8859-1...

Some idea???

Thanks a lot and sorry for me english!!

4

1 回答 1

1

查看文档,似乎没有一个名为的选项- 但在-optionencoding上有一个不错的小提示(包括您的问题的解决方案) :contentType

数据将始终使用 UTF-8 字符集传输到服务器;您必须在服务器端对此进行适当解码。

所以看起来firefox是对的,而其他浏览器做错了-尝试删除encoding-option并进行服务器端转换。

于 2012-05-04T07:10:34.283 回答