First, to unify the MyEclipse character encoding, the steps are as follows: 1, enter the default (GBK) in the Window--preferences--general--workspace,text file encoding option Change the option to other and set the value to Utf-8;2, enter Window--preferences--myeclipse--files and Editors, and this option will be the following: ASP and PHP, CSS, DTD, HTML, JSP, The character encodings in the XML are all changed to utf-8;3, and if necessary, add this line of code to all JSP page headers: <%request.setcharacterencoding ("UTF-8"); %>, prevent the page to pass the value of the time garbled; 4, if you call the servlet file, add the following two lines of code in the servlet file: request.setcharacterencoding ("UTF-8"); Response.setcharacterencoding ("UTF-8");
Next, set up the Hibernate profile:
Hibernate.cfg.xml plus attributes.
<property name= "Connection.useunicode" >true</property>
<property name= "Connection.characterencoding" >UTF-8</property>
Finally, the character encoding of the database should also be set:
Modify database encoding: ALTER DATABASE name character Set UTF8
Open the MySQL installation directory under the configuration file My-default.ini find Default-character-set This line and modify the Default-character-set=utf8, if not add this sentence.
Myeclipse+hibernate writing MySQL data garbled problem