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. 跟著課件一模一樣的操作使用tp6,出現(xiàn)了錯誤2. PHP類屬性聲明?3. macos - mac下docker如何設(shè)置代理4. javascript - 為何CreateElement之后,在這標(biāo)簽前插入子節(jié)點,沒用5. javascript - 求助關(guān)于call和apply的問題,反柯里化6. 用TP6寫的HTML,我的layui樣式為什么出不來,路徑?jīng)]錯,頁面報錯:不允許加載本地資源:fil7. css3怎么讓img上下左右居中8. css3 - 圖文響應(yīng)式樣式9. css - 手機瀏覽器的兼容問題,微信和其它下載的瀏覽器打開沒有問題,谷歌也測試過,就是手機自帶的瀏覽器有問題。10. javascript - 求助大問題!!!!!這輸出為什么能不一樣
