Eclipse MySQL Hibernate 中文乱码问题
生活随笔
收集整理的這篇文章主要介紹了
Eclipse MySQL Hibernate 中文乱码问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
如果是Eclipse的問題,那就對以下各項進行設置,即可排除問題。
設置eclipse相關編碼為UTF-8:
修改工作區默認編碼,位置:windows--perferences--general--workspace
修改JSP文件默認編碼,位置:windows--perferences--web--jsp files
修改JSP文件默認編碼,位置:windows--perferences--general--content types--text--jsp file
修改配置文件默認編碼:位置:windows--perferences--general--content types--text--Java properties file
設置自動格式化代碼:選中format source code--format all lines,位置:windows--perferences--Java--editor--save actions
如果是問題是在Hibernate讀寫數據時,
要對hibernate連接數據庫的xml配置文件添加兩項:
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">utf8</property>
總結
以上是生活随笔為你收集整理的Eclipse MySQL Hibernate 中文乱码问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue2.0组件之间传递数据
- 下一篇: 大语言模型的开发利器langchain