文字-字节流-编码
作者:
wswenyue | 来源:发表于
2014-10-03 20:38 被阅读31次private void test(HttpServletResponse response) throws IOException,
UnsupportedEncodingException {
// 在服务器端,用何种编码方式编码,浏览器端也要用何种编码方式编码。
String data = "中国";
// 告诉浏览器以某种编码方式打开
response.setHeader("Content-type", "text/html;charset=UTF-8");
//response.setContentType("text/html;charset=UTF-8");//这行代码可以替代编码设置的两条命令
//规定response以UTF-8编码
response.setCharacterEncoding("UTF-8");//UTF-8为国际码,开发通用
PrintWriter out =response.getWriter();
out.write(data);
}
本文标题:文字-字节流-编码
本文链接:https://www.haomeiwen.com/subject/amoutttx.html
网友评论