spring jdbcTemplate添加数据库乱码

802 查看

用spring开发项目时,有时向数据库添加数据时会乱码,明明数据库已经是utf8编码了但是会乱码。解决方案就是:

1、在applicationContext.xml中的连接数据库的url修改为下面配置

xml    url="jdbc:mysql://localhost:3306/xx?useUnicode=true&characterEncoding=UTF-8