Summed up a few garbled problems hope that we all students can also learn to summarize
Java Web is very hope that everyone can learn. And also hope that we can in the learning process of the accumulation of relevant knowledge points
1, write in response <meta http-equiv= "Content-style-type" content= "text/html;charset=gb2312" >
2. Use new String (character variable. getBytes ("Iso-8859-1"), "gb2312")
3, in the JSP processing garbled problem is resolved as follows
String variable name = "Hello";
Lpara = Java.net.URLEncoder.encode (new String (variable name. GetBytes ("GBK"), "iso8859-1"));
<a href= "Yourservlet? Para=<%=lpara%> ">Test</a>
...
Yourservlet:
String lpara=request.getparameter ("Para");
4. Before you get the value of the variable (request.getparameter ("Control Name on Interface"), add the following code
Response.setcontenttype ("text/html;charset=gb2312");
Request.setcharacterencoding ("gb2312");
Respose.setcharacterencoding ("gb2312");
5. Ensure that the Chinese processing code in the servlet (3 lines of code in method 4) precedes the PrintWriter object
PrintWriter out = Response.getwriter ();
6, if the operation of the action of the operation is still garbled problem:
Note on the page Tanji right---code--to Chinese (OK)
7, if the above 1~6 operation or can not solve the Chinese problem:
Change server operation even if (a different Tom cat is posting or using JBoss release)
8. Provide reference only
Servlet Chinese garbled solve "use filter"
If it is not garbled when committing to the server side, it is the problem of MySQL connection string.
For example, I use GBK, the connection string is:
Jdbc:mysql://localhost:3306/test?autoreconnect=true&useunicode=true&characterencoding=gbk
That's what utf-8 should be.
Jdbc:mysql://localhost:3306/test?autoreconnect=true&useunicode=true&characterencoding=utf8
& is the & symbol, I am in the XML file configuration practical, if you do not use XML configuration, it is written directly &
Troubleshoot MySQL garbled