1.问题描述
中文字段乱码,不能正常显示
2.解决方法
猜测是未指定编码造成的,在配置文件mybatis-config.xml添加配置。
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<!--数据库连接信息-->
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://192.168.1.xxx:3306/mybatis?useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="xxxxxx"/>
</dataSource>
</environment>
3.验证
再次执行插入动作,不再乱码。