One: HTML garbled or the introduction of JS garbled
1: The first step, text file encoding
First make sure the file is saved in UTF-8 format, such as in Eclipse, to point attributes on the file, make sure to select UTF-8
Note that the JS file created by default in Eclispe, its encoding is GBK, note must be changed back.
2:pageencoding
Make sure that the pageencoding of the HTML file or JSP file is utf-8.
Note that the default HTML or JSP file created by Eclipse, whose pageencoding is iso-8859-1, must be changed back, as follows:
Other precautions to keep in mind
If at first forget to change pageencoding back, and then input Chinese in the file, this time will text-file-encoding to UTF-8 words, the file already exist in Chinese will become garbled.
Second: garbled characters in the process of post-transfer of web page
Suppose a Web page post is passed to the B page. First, make sure that the a page meets the above description, and secondly, on page B, the following processing is required:
Response.setcontenttype ("Text/html;charset=utf-8");
Request.setcharacterencoding ("Utf-8");
String empno = Request.getparameter ("Empno");
Third: Web page URL value process garbled
First, the URL of a Web page is encoded, similar to the following:
<a href= "Delete.jsp?ename=<%=java.net.urlencoder.encode (Rs.getobject (" ename "). ToString ()," Utf-8 ")%>" > Delete </a>
Then, on page B, you need:
String msg = Request.getparameter ("ename");
String Ename=new string (msg.getbytes ("iso-8859-1"), "UTF-8");
Several solutions to the Java development of Chinese garbled characters