jsp,mysql中文乱码一般解决方法
jsp中文乱码解决方法
1-设置jsp页面<%@ page contentType="text/html; charset=gb2312" %>
2-表单提交后接收字符使用request.setCharacterEncoding("gb2312"); 或者使用servelet过滤器的方法。
mysql中文乱码解决方法
1-使用mysql5.0时在设置向导中的“please select the default character set” 选择“manual selected default character set/collaction”这项,在字符集 中选择使用gb2312字符集!
2-在jsp中进行数据库连接时使用的连接字符串 "jdbc:mysql://localhost/database?useUnicode=true&characterEncoding=gb2312"
搜索更多相关主题的帖子:
mysql中文 jsp 乱码 过滤器 数据库
----------------解决方案--------------------------------------------------------
再加上开发struts时使用中文资源文件时出现中文乱码的解决方法: 首先建立application_temp.properties中文的资源临时文件。里面是用中文写的属性和值,例如: hello.jsp.page.heading=Hello World! 第一个Struts应用 然后在cmd命令行中运行 native2ascii -encoding gb2312 application_temp.properties application_zh_CN.properties 下面就可以发现在放application_temp.properties的文件夹下多了一个application_zh_CN.properties 文件,用记事本打开后可以看到属性和值已经转换了编码 hello.jsp.page.heading=Hello World! \u7b2c\u4e00\u4e2aStruts\u5e94\u7528 最后在jsp文件中调用这些资源文件中的值时就会正常显示中文了!
[此贴子已经被作者于2005-10-12 11:08:27编辑过]
----------------解决方案--------------------------------------------------------
自己顶一个!
----------------解决方案--------------------------------------------------------
恩
不错
好东西
----------------解决方案--------------------------------------------------------
顶你一个!
----------------解决方案--------------------------------------------------------
我要学好这个 一定要 不是单纯的兴趣跟学习
----------------解决方案--------------------------------------------------------
受益,
----------------解决方案--------------------------------------------------------
看了,还可以。谢谢了
----------------解决方案--------------------------------------------------------
感谢
----------------解决方案--------------------------------------------------------