- 編輯mysql的配置文件my.ini,設(shè)置字符集為gbk
[client]
port=3306
[mysql]
default-character-set=gbk
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/MySQL/MySQL Server 5.1/"
#Path to the database root
datadir="D:/Program Files/MySQL/MySQL Server 5.1/Application Data/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gbk
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
- 使用MySQL Workbench設(shè)計數(shù)據(jù)庫 ,數(shù)據(jù)庫和表均使用默認(rèn)的字符集
- 在Servlet中轉(zhuǎn)換字符編碼
String name = request.getParameter("name");
name = new String(name.getBytes("ISO-8859-1"));
- 設(shè)置JSP頁面字符集為GBK
<%@ page language="java" pageEncoding="GBK"%>