来源:http://blog.csdn.net/xiaoxuonl/article/details/54315612
服务器返回的是utf-8,jsp页面上也是utf-8,数据库也是utf-8怎么就是乱码呢!!!!
在网上天昏地暗地找了两天总算有解决方案了:
问题出在getHttpResponse 输入流!
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
改为
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
找了两天都快哭了总算解决了
///////////以下如果都试过了还无效,你可以找找你的输入流输出流是不是有问题////////////////
URLDecoder.decode(URLDecoder.decode(json, "GBK"), "UTF-8");
response.setContentType("text/html;charset=utf-8");
json =new String(json.getBytes(),"UTF-8");