The solution to the database garbled by the JSP value to the JSP Chinese garbled value
All the unified utf-8 used in the code
1. The place to choose the coded interface when you install MySQL select Utf-8 encoding
2 Choosing a character set collation when building a database all UTF8--UTF-8 Unicode utf8_general_ci
3 Setting the table when the character set collation is all the same as above
There's a database over here, okay?
Next is the JSP side
4 header additions for all JSP pages
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<% @page contenttype= "text/html; Charset=utf-8 "%>
5 Connecting the database Javaservlet inside
String cc= "Com.mysql.jdbc.Driver";
String server= "Jdbc:mysql://127.0.0.1:3306/test1?useunicode=true&characterencoding=utf-8";
String user= "root";
String pwd= "";
6 Project Web. XML inside the head
<?xml version= "1.0" encoding= "UTF-8"?>
7. Use Tomcat's friends in the configuration server.xml inside
Head <?xml version= ' 1.0 ' encoding= ' utf-8 '?>
Then someone said configure the Tomcat configuration file Server.xml in this sentence:
<connector
port= "8080" maxhttpheadersize= "8192"
maxthreads= "minsparethreads=" maxsparethreads= "75"
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
connectiontimeout= "20000" disableuploadtimeout= "true"/>
Add this sentence: uriencoding= "UTF-8"
8. Forget a project in progress also to Utf-8, right click on the project properties inside resource inside Set
I believe you will not appear garbled, haha.
If the JSP is a value JSP, you can also use the strong turn function
String name=request.getparameter ("name"), modified to
String Name=new string (Request.getparameter ("name"). GetBytes ("Iso-8859-1"), "Utf-8");
This will show the Chinese. Of course it's troublesome if too much.