For post requests, just write the following code in the servlet or JSP to resolve the Chinese garbled problem passed in from the form
Request.setcharacterencoding ("Utf-8");
For GET requests, because the request parameters are appended to the URL of the address bar, you cannot use the above processing method. It should be like this:
String str=request.getquerystring ();
Use Urldecoder to decode strings string
str1=java.net.urldecoder.decode (str, "Utf-8");
String[] Parastrings=str1.split ("&");
Parastrings[0] is the first argument, and so on
... for (String parastring:parastrings)
{
string[] namevalue=parastring.split ("=");
Namevalue[0] is the form's name,namevalue[1] is the value of the form name
Another method is to encode the request parameter value after obtaining the request parameter, that is, converting it to a byte array, then decoding the byte array into a string.
String str=request.getparameter ("name");
Byte[] Bytes=str.getbytes ("iso-8859-1");
String name=new string (bytes, "Utf-8");
The above perfect solution to get and POST request Chinese garbled problem is small series to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud-dwelling community.