response.setHeader("content-type", "text/html;charset=UTF-8");
String data="中国";
OutputStream out =response.getOutputStream();
out.write(data. getBytes("UTF-8"));
--------------------------------------------------------------------
String data="你好";
//设置response使用的码表,以控制response以什么码表向浏览器写出数据
response.setCharacterEncoding("UTF-8");
//指定浏览器以什么码表打开
response.setHeader("content-type", "text/html;charset=UTF-8");
PrintWriter pw=response.getWriter();
pw.write(data);
-------------------------------------
//或者直接使用一条语句
response.setContentType("text/html;charset=UTF-8");