码迷,mamicode.com
首页 > Web开发 > 详细

web乱码问题

时间:2015-12-02 22:11:45      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

String data = "不见青山";
ServletOutputStream sos = response.getOutputStream();
byte b[] = data.getBytes();  //默认用平台的gbk编码
sos.write(b)
------------------------------------------------------------------------
(1) response.setHeader("Content-Type", "text/html;charset=UTF-8");
(2) response.setContentType("text/html;charset=UTF-8");
String data = "不见青山";
ServletOutputStream sos = response.getOutputStream();
byte b[] = data.getBytes("UTF-8");  //默认用平台的gbk编码
sos.write(b)


字符
(1) response.setCharacterEncoding("UTF-8");
(2) response.setContentType("text/html;charset=UTF-8");
String data = "春天里";
PrintWriter pw = rsponse.getWriter();
pw.write(data)//默认用ISO-8859-1

以上为response响应乱码解决问题



提交乱码

技术分享

web乱码问题

标签:

原文地址:http://www.cnblogs.com/tuifeideyouran/p/5014150.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!