Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2160824
  • 博文数量: 556
  • 博客积分: 11457
  • 博客等级: 上将
  • 技术积分: 5973
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-24 22:33
文章分类

全部博文(556)

文章存档

2013年(22)

2012年(74)

2011年(460)

分类: 系统运维

2012-03-10 22:24:56

记住一点:
你以什么方式或者编码写的数据就要告诉浏览器以什么方式或者码表打开,否则会出现乱码。

点击(此处)折叠或打开

  1. public void doGet(HttpServletRequest request, HttpServletResponse response)
  2.             throws ServletException, IOException {
  3.           test(response);
  4.     }
  5.    
  6.      public void test(HttpServletResponse response) throws UnsupportedEncodingException, IOException{
  7.          response.setHeader("Content-type","text/html;charset=UTF-8"); //指定消息头以UTF-8码表读数据
  8.          String data="中国";
  9.          response.getOutputStream().write(data.getBytes("utf-8"));
  10.      }
阅读(3567) | 评论(0) | 转发(0) |
0

上一篇:使用游标

下一篇:junit测试简单实例

给主人留下些什么吧!~~