java - spring操作數(shù)據(jù)庫顯示中文亂碼的問題?
問題描述
操作系統(tǒng):ubuntuIDE:idea數(shù)據(jù)庫:Mysql我用php操作數(shù)據(jù)庫的時候中文顯示是沒有問題的,可以正常顯示中文:
但是我學(xué)習(xí)spring的時候操作數(shù)據(jù)庫的時候中文就會出現(xiàn)問號,無法正常顯示
我在spring中寫的數(shù)據(jù)庫配置
# 在項目初始化時,重新創(chuàng)建數(shù)據(jù)表spring.jpa.hibernate.ddl-auto=update# 指定連接的類型為mysql 連接的地址為:localhost 端口為3306 ,數(shù)據(jù)為springmvcspring.datasource.url=jdbc:mysql://localhost:3306/springmvc# 用戶名為rootspring.datasource.username=root# 密碼為空spring.datasource.password=# 顯示SQL語句spring.jpa.show-sql=true
我的數(shù)據(jù)庫和idea都是用的utf_8編碼,為什么會出現(xiàn)這種問題呢?
問題解答
回答1:修改
spring.datasource.url=jdbc:mysql://localhost:3306/springmvc
為
spring.datasource.url=jdbc:mysql://localhost:3306/springmvc?useUnicode=true&characterEncoding=utf-8
相關(guān)文章:
1. html - vue項目中用到了elementUI問題2. mysql scripts提示 /usr/bin/perl: bad interpreter3. showpassword里的this 是什么意思?代表哪個元素4. css3 - border-bottom 的長度可否超過盒子的寬度呢?實現(xiàn)如下圖效果。(我的書下面的線)5. android - 用textview顯示html時如何寫imagegetter獲取網(wǎng)絡(luò)圖片6. 對mysql某個字段監(jiān)控的功能7. css3 - css怎么實現(xiàn)圖片環(huán)繞的效果8. javascript - 原生canvas中如何獲取到觸摸事件的canvas內(nèi)坐標(biāo)?9. JavaScript事件10. mysql優(yōu)化 - mysql EXPLAIN之后怎么看結(jié)果進行優(yōu)化 ?
