我遇见过两种情况,
1 用hibernate连接数据库 ,连接字符串加上后面的代码
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/storage?useUnicode=true&characterEncoding=utf8"/>
2 用struts2 写连接类
private static final String url = "jdbc:mysql://localhost:3306/yuqing?useUnicode=true&characterEncoding=utf8";
这两种情况写的不太一样 ,我也不知道为什么 反正我这两种都可以实现了