_Ritchie

解决前台向mysql更新数据的编码问题

在数据库连接的最后加上useUnicode=true&characterEncoding=utf8
例如:

jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8

同时需要注意的,使用post方法,需要设置

request.setCharacterEncoding("utf8");

使用get方法,需要对获得的数据进行编码解析

String rawQueryStr = request.getQueryString();
String queryStr = java.net.URLDecoder.decode(rawQueryStr, "utf8");

posted on 2015-07-11 00:04  _Ritchie  阅读(142)  评论(0编辑  收藏  举报

导航