mysql中文问题
1.创建数据库表
mysql>Create DATABASE IF NOT EXISTS (databasename) default charset utf8 COLLATE utf8_general_ci;
但在MySQL Query Browser中看到的是乱码,传给前端也是乱码。
解决方法:
在hibernate.cfg.xml中应该这样写
<property name="connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true& characterEncoding=UTF-8</property>
如果用hibernate.properties
#hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
字节编码问题最好的解决方法还是统一使用UTF-8!!!
mysql>Create DATABASE IF NOT EXISTS (databasename) default charset utf8 COLLATE utf8_general_ci;
但在MySQL Query Browser中看到的是乱码,传给前端也是乱码。
解决方法:
在hibernate.cfg.xml中应该这样写
<property name="connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true& characterEncoding=UTF-8</property>
如果用hibernate.properties
#hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
字节编码问题最好的解决方法还是统一使用UTF-8!!!
用程序书写人生,用代码编织快乐

浙公网安备 33010602011771号