views:

72

answers:

2

we have a wep application, when using chinese words in GET query string can not get correct parameter on server side but in POST data we can get correct parameter on server side. server is Tomcat. on server side we use GBK encoding to get HTTP parameters if I convert encoding of parameters in in query string from ISO8859-1 to GBK it's right but the problem is there are too many JSP pages to change.so I wanna if there is anyway to configure IE to send query string using GBK but iso8859-1. I tried to uncheck "send UTF-8 url" option of IE ,it did not work for me...

PLZ HELP SORRY FOR MY BAD ENGLISH!

//iPostChange int 0:ISO8859_1,1:NoChange,2:ISO8859_1->GBK,3:GBK->ISO8859_1,5:GBK

String sFlowNo = DataConvert.toRealString(iPostChange,(String)CurComp.getParameter("FlowNo"));

iPostChange is used to set encoding converting, default is 1 which means dont change . FlowNo is supposed to be some Chinese words, if FlowNo is passed to server in url(HTTP GET query string)with default iPostChange I cant get right Chinese string, but if FlowNo is passed to server in a Form(using POST method)I can get right Chinese string.

is that IE8 did not support using Chinese characters in URL ?

A: 

fixed.

see : Tomcat wiki

Tomcat will use ISO-8859-1 as the default character encoding of the entire URL, including the query string ("GET parameters"). There are two ways to specify how GET parameters are interpreted:

  1. Set the URIEncoding attribute on the element in server.xml to something specific (e.g. URIEncoding="UTF-8").

  2. Set the useBodyEncodingForURI attribute on the element in server.xml to true. This will cause the Connector to use the request body's encoding for GET parameters.

idiotgenius
A: 

It's best not to rely on the character encoding in GET requests, as some browsers will encode them in UTF-8 and others will encode them as ISO-8859-1. Furthermore, the encoding that is enforced depends on the encoding of the page that submitted the form - so, while one form on a page encoded in UTF-8 will lead to an UTF-8 encoded GET request, a similar form on a page with ISO-8859-1 encoding will lead to an ISO-8859-1 encoded request.

See also http://stackoverflow.com/questions/1549213/whats-the-correct-encoding-of-http-get-request-strings/1549498#1549498 for a more detailed explanation.

Geert
yes! I totally agree.but I am maintaining a legacy System.tonsof JSP pages !:D
idiotgenius