I believe that everyone in the web development will encounter garbled problems, there are page garbled, request garbled, database garbled, and so on, here I enumerate the different cases of garbled solution:
1. The corresponding data garbled:
Just write the phrase in the background interface method to specify that the response character set is Utf-8
Response.setcontenttype ("Text/html;charset=utf-8");
2. Request data garbled:
①.get Request:
The first way the Tomcat default character set is Iso8859-1, you can manually convert it to the desired character set, manually transcoding;
The second way, configure the filter, use filter;
Third Way, directly modify the Tomcat configuration
<port= "8080" protocol= "http/1.1" connectiontimeout = "20000" redirectport= "8443" uriecoding= "UTF-8" />
②post Request:
Request.setcharacterencoding ("Utf-8")
3. Database garbled:
Jdbc:useunicode=true&characterencoding=utf-8 create table xxx () engine Default Charset=utf-8
4.html file
<charset= "Utf-8">
5. Project code set to Utf-8
Garbled problems encountered in web development