When you log in, submit a user name of Chinese name to the server and return to the cookie in the client,
This process will be reported in the background java.lang.IllegalArgumentException (illegal data exception)
URL-encode the data before you send the cookie to the foreground.
-->urlencoder.encode (username, "Utf-8")
After resolving the coding problem in the background, the foreground can accept the cookie value, and then receive a similar: "%E7%AB%A5%E6%97%AD%E5%B9%B3" data, then use the ISO8859-1 Code table to read the user name information.
URL decoding of the data after the cookie value is obtained.
-->username = Urldecoder.decode (username, "utf-8");
The main cause of the above problem is that the server by default is using the Iso8859-1 Code table to encode and decode the data. Then we need to do URL decoding of the data.
Classes for URL encoding and decoding are available in Java
converts the specified string to a URL- encoded form According to the specified encoding
Urlencoder:static string encode (string name,string enc);
decodes a URL- encoded string into a source string according to the specified encoding
Urldecoder:static string decode (string name,string enc);
Use cookies to remember the user name garbled problem (URL encoding)