Generally, the Tocant url encoding is iso-8859-1 (check that the Connector node in tocat/conf/server. xml does not write URIEncoding = "xxxxxx") as follows:
Copy codeThe Code is as follows:
<Connector port = "8080" protocol = "HTTP/1.1"
ConnectionTimeout = "20000"
RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>
If we write the following code in servlet:
Copy codeThe Code is as follows:
String username = request. getParameter ("name"); // name is the parameter from the get request. Here the byte code from the get request has been converted to the code of the iso-8859-1, decoding error
Byte [] B = username. getBytes ("iso-8859-1"); // so you need to re-convert to bytecode, and then use the correct encoding method to decode, the correct encoding method is the jsp that page encoding method,
Username = new String (B, "GBK ");
System. out. print (username );