在 database 和 table 都是 utf8 编码的前提下,
在 hibernate.cfg.xml 的 <session-factory> 结点中加入
<property name="connection.characterEncoding">utf8</property>
若整合了 Spring 和 Hibernate,在 applicationContext.xml 中的指定 datasource 的 bean 结点中这样做:
<property name="jdbcUrl" value="jdbc:mysql://localhost/dbname?characterEncoding=utf8"/>
本文介绍如何在整合Spring和Hibernate的项目中正确设置数据库连接的UTF8字符集,确保数据在传输过程中的正确编码。
1458

被折叠的 条评论
为什么被折叠?



