This is caused by the server, such as Tomcat receives the get method by default using ISO-8859-1 encoding, while the browser sends the text encoding is consistent with the page encoding, if the page is using UTF-8 encoding get method text is naturally using UTF-8 encoding, but the receiving server is not set with the ISO-8859-1 encoding to receive, the Chinese will naturally become garbled, however, since ISO-8859-1 encoding is single-byte encoding, we can use getbytes ("ISO-8859-1"), "UTF-8" to re-convert the text to UTF-8 encoding.
The first sent text is UTF-8 encoded and Tomcat is encoded with the wrong ISO-8859-1 after receiving, so that getbytes ("ISO-8859-1") will get the correct UTF-8 encoded byte array again, then use new
String (request. getparameter ("something"). getbytes ("ISO-8859-1"), "UTF-8") recode byte into UTF-8-encoded text so that the text is correct.
If Tomcat is used
<Connector Port = "80" protocol = "HTTP/1.1"
Connectiontimeout = "20000" redirectport = "8443" uriencoding = "UTF-8"/>
The uriencoding at the end is to set the get method encoding. If the encoding type received by the URL is not specified, it will be automatically encoded by the ISO-8859-1.
The error message returned when the get method is garbled.