Hibernate持久化数据中文乱码

阅读 41

2022-06-24

Hibernate持久化数据中文乱码
数据库编码为utf-8,开发环境编码也为utf-8,插入中文数据仍旧乱码

解决方法:

修改Hibernate.cfg.xml中的hibernate.connection.url的值
即在数据库名称后面加上参数?useUnicode=true&characterEncoding=UTF8

<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8</property>


精彩评论(0)

0 0 举报