1. Garbled when the server returns the data to the client as Chinese:
(1) When the server converts a string to a byte, you can specify the encoding format: Response.getoutputstream (). Write ("Login succeeded". GetBytes ("UTF-8");
The default Code table Iso-8859-1 contains no Chinese characters.
(2) Client time conversion: String temp = new String ("Login succeeded", "GBK");
2. The client app receives garbled text when it is passed to the server in the edit box:
(1) System.out.println ("username" +new String (Username.getbytes ("iso-8859-1"), "UTF-8"));//Convert the scrambled code into the original binary, and then reassemble the binary. (The conversion is performed before the transfer, which transmits the encoded data)
String Path = "Http://172.18.22.209:8080/GetTest/servlet/LoginServlet?username" +
Urlencoder.encode (username, "utf-8") + "&password" +urlencoder.encode (password, "Utf-8");
String data = "username=" +urlencoder.encode (username, "utf-8") + "&password=" +urlenoder.encode (password, "Utf-8") ;
(2) httppost.setentity (new Urlencodedformentity (Pamars, "UTF-8"));
Refuse to garbled