At the end of last semester web development of the big job, asked to write a wanted to manage the system, the basic function to realize that is nothing more than database additions and deletions to check. It's easy to achieve, but it's been a long time in some detail. One of them is the Chinese garbled problem. The main concerns are two areas:
One, unable to insert the Chinese data in the MySQL database, once the Chinese data is involved, it will become garbled in the database. After query discovery is due to the problem of the default encoding setting of the database, the encoding of the corresponding table and column is set to UTF-8.
Second, the page display garbled.
1. Through <%@ page language="java" import="java.util.*" contenttype= "text/html"; Charset=utf-8 "%> The encoding of the specified page
2. The background accepts Chinese parameters using the new String (Str.getbytes ("iso-8859-1"), "UTF-8") for encoding conversion.
Through this debugging bug experience, I know that encountered problems first need to analyze the cause of the problem, only to know the reason to solve, learning to analyze the source of the problem is far more important than solving the problem.
And the reason for the garbled problem is that the coding of the program is not the same as the coding of the programmer, so the solution to this problem only needs to be programmed to tell the programmer the code to the program can be, the above methods to solve garbled problem can be said to be a process of declaring code, that is, the ultimate solution to garbled problem is transcoding.
[Software Test _HW1] Remember the experience of debugging a bug