日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

ssh linux mysql 乱码_JAVA ,SSH中文及其乱码问题的解决 6大配置点 使用UTF-8编码

發(fā)布時(shí)間:2025/4/5 数据库 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ssh linux mysql 乱码_JAVA ,SSH中文及其乱码问题的解决 6大配置点 使用UTF-8编码 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

JSP,mysql,tomcat下(基于struts2)中文及其亂碼問題的解決 6大配置點(diǎn) 使用UTF-8編碼

目前對遇到J2EE 開發(fā)中 中文及其亂碼問題,參考網(wǎng)上資料做個(gè)總結(jié), 主要是6大配置點(diǎn):

1 struts2配置 2 數(shù)據(jù)庫 3 頁面 4 jdbc連接 5 tomcat 6.hibernate配置

以下解決方法不分順序,大家按照自己的配置對比,同時(shí)也歡迎大家補(bǔ)充

1 struts2配置

struts2在配置struts.properties文件中加上struts.i18n.encoding=UTF-8?或者在struts.xml里加上 有的朋友說加上struts.locale=zh_CN,但是我的struts.locale為en_GB沒有問題.

2 數(shù)據(jù)庫

2.1 mysql的表的編碼方式,其DDL應(yīng)該為: ENGINE=InnoDB DEFAULT CHARSET=utf8; 可以使用show create table tbname查看.

2.2 安裝mysql數(shù)據(jù)庫時(shí)就應(yīng)該以utf8編碼默認(rèn)安裝查看mysql數(shù)據(jù)庫默認(rèn)編碼方式可以在其目錄下my.ini文件中找到mysql和mysqld下default-character-set值為utf8或者在mysql數(shù)據(jù)庫命令行下以"/s;"查看.

3 頁面

每個(gè)頁面上加上< %@page?pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> 這樣在jsp頁面里,點(diǎn)右鍵,查看編碼方式則為UTF-8.

4 jdbc連接

設(shè)置characterencoding為UTF-8 如jdbc.mysql.url=jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=UTF8

5 tomcat

為了保證get/post數(shù)據(jù)都采用相同的UTF8編碼,我們在server.xml中進(jìn)行了如下設(shè)置:

其中,當(dāng)當(dāng)使用IIS作為webserver轉(zhuǎn)發(fā)servlet/jsp請求時(shí)IIS是通過AJP協(xié)議,把請求轉(zhuǎn)發(fā)到Tomcat監(jiān)聽的8009端口,所以需要配置端口8009的URIEncoding為UTF-8.

msyql數(shù)據(jù)庫安裝時(shí)候需要默認(rèn)編碼方式或者使用MySQL Server Instance Config Wizard 配置,

在設(shè)置Configure the MySQL Server 5.0 server instance那里的時(shí)候選擇Manual Selected Default Character Set / Collation 為 UTF8 而不是默認(rèn)的 LATIN1 在MYSQL里查看得 mysql> /s;

-------------- E:/MySQL/MySQL Server 5.0/bin/mysql.exe? Ver 14.12 Distrib 5.0.51a, for Win32 (ia32) Connection id:? ? ? ? ? 2 Current database: Current user:? ? ? ? ? [email?protected] SSL:? ? ? ? ? ? ? ? ? ? Not in use Using delimiter:? ? ? ? ; Server version:

5.0.51a-community-nt MySQL Community Edition (GPL) Protocol version:? ? ? 10 Connection:? ? ? ? ? ? localhost via TCP/IP?Server characterset:? ? utf8 Db? ? characterset:? ? utf8 Client characterset:? ? utf8 Conn.? characterset:

utf8?TCP port:? ? ? ? ? ? ? 3306 Uptime:? ? ? ? ? ? ? ? 25 sec Threads: 1? Questions: 4? Slow queries: 0? Opens: 12? Flush tables: 1? Open tables: 6? Queries per second avg: 0.160

my.ini文件內(nèi)容為

[mysql]?default-character-set=utf8?# 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="E:/MySQL/MySQL Server 5.0/" #Path to

the database root datadir="E:/MySQL/MySQL Server 5.0/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=utf8?...........

6. H ibernate 配置

在hibernate.cfg.xml配置文件中加入這些來完成的

true

UTF-8

作者:risingsun001 發(fā)表于2013-9-2 22:16:40 原文鏈接

閱讀:0 評論:0 查看評論

總結(jié)

以上是生活随笔為你收集整理的ssh linux mysql 乱码_JAVA ,SSH中文及其乱码问题的解决 6大配置点 使用UTF-8编码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。