我有一个问题,是关于中文乱码问题。
我用的是Eclipse3.1+tomcat5.5+struts,数据库是SQLServer。
在添加时JSP页面用的是<%@ page contentType="text/html;charset=gb2312"%>标签;
用FormBean接收,输出到后台时是乱码,但写到数据库中则是中文;
但为什么从数据库提取纪录输出到页面时还是乱码呢?
我很着急,希望各位前辈多多指点我,我会给分的!!!!!!
我用的是Eclipse3.1+tomcat5.5+struts,数据库是SQLServer。
在添加时JSP页面用的是<%@ page contentType="text/html;charset=gb2312"%>标签;
用FormBean接收,输出到后台时是乱码,但写到数据库中则是中文;
但为什么从数据库提取纪录输出到页面时还是乱码呢?
我很着急,希望各位前辈多多指点我,我会给分的!!!!!!
用这个设置一下看看好用不
request.setCharacterEncoding("gb2312");
http://www.blogjava.net/rickhunter/articles/33571.html
http://www.newxy.net/doc.jsp#anchor5.5
网页encoding也用UTF-8,什么事都不会有,随便几种语言
像这样 N'你好',存进去的是unicode。
sql server2005没有用过不知道。
1: 安装MySQL数据库时候就指定字符集合为gbk或者gb2312,只要数据库中显示正常中文字符的话,页面肯定显示正常,哪来这么多的转换,烦死了!!
2: 指定服务器的 编码 GBK 或者GB23123: 修改安装目录下的 初始化配置文件 my.ini# 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="E:/MySQL5/"#Path to the database root
datadir="E:/MySQL5/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=latin1 换成 gbk 或者 gb2312# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB