Server Set Value (Chinese) to interface using two times encoding:
1 String pagejson=urlencoder.encode (Urlencoder.encode (str, "GBK"), "GBK"); 2 request.setattribute ("Pagejson", Pagejson);
Then in the interface and received the value to the background, with the Address bar direct URL:
Window.location.href= "... Test.do?method=test&pagejson=${pagejson}";
Decode directly in the background:
String Pagejson=urldecoder.decode (Request.getparameter ("Pagejson"), "GBK");
At this time the decoded value is garbled, the page Setup encoding format is also GBK, and not decoded before directly get the value of the parameter is garbled (in fact, no need to decode).
Should be uploaded to the server when the browser automatically decoded.
So add:
String pagejson=New string (Pagejson.getbytes ("iso-8859-1"), "GBK");
It's settled. In fact, although the page is encoded after the format, but is through window.location.href such a way to request to the background, so the browser automatically decode, with the usual general URL parameters submitted to the background is the same, the general request the default encoding format is Iso-8859-1, It is independent of the format of the page setup, and can be converted in normal format.
Java encoding and decoding garbled problem