web乱码问题

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乱码问题_第1张图片

你可能感兴趣的:(web乱码问题)