One.
Because Doget and dopost are handled differently, there is a problem when doing a servlet: The parameters obtained with Dopost are added "request.setcharacterencoding (" Utf-8 ") as a line, The display of Chinese will not garbled, but the parameters obtained by doget with "request.setcharacterencoding (" Utf-8 ")" This line is still garbled, the solution is as follows:
1. This one is a once and for all method, found from the Internet
Locate the Conf/server.xml file in your Tomcat server root directory, locate the line in the file, and change the uriencoding= "" double quotation mark inside to Utf-8, which is the red font.
As follows:
<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "8443" uriencoding= "Utf-8"/>
2. The following method is taught by a teacher, such as:
String name=request.getparamter ("name");
String Username=new string (name.getbytes ("iso-8859-1"), "Utf-8");
This is forced transcoding using the transcoding function of the string. Note:. GetBytes () If it is a Chinese operating system, the default is to use GB2312 encoding.
Two.
Use the output to the page in the following way: Response.setheader ("Content-type", "text/html;charset=utf-8");
Jsp+servlet Chinese garbled problem