以 utf8 为例,第一步:检查服务器端 mysql 安装目录下有个叫 my.ini 的配置文件,修改

[mysql]

default-character-set=utf8,这里说明一下,数据库里的编码跟页面不一样,是 utf8 而不是 utf-8.

第二步,修改你建的数据库的编码,在data目录下找到你建的数据库,打开 db.opt 修改 default-character- set=utf8

以上两步为服务器端的设置。

第三步,程序里的设置,在连接数据库的 url 后面加上一个参数 ?characterEncoding=UTF-8 说明我们以这个字符编码跟数据库进行通信。

第四步,实际上这一步是为我们在页面间传递汉字来设定的,比如说搜索关键字,这样的话需要在 tomcat 的 conf/server.xml 的 Connector 标签里加上 URIEncoding="UTF-8"

所以说如果遇到字符编码有问题的话,就按照这些个步骤,一点一点慢慢来匹配。

—-2009/10/29

Tags: ,

Related posts

Tags: ,.
Home

No Comments Now!

Be the first to comment on this entry.

Leave a comment

Name(required)
Mail (required),(will not be published)
Website(recommended)

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs must be fully qualified (eg: http://hanghang.name),and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.