您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页文字-字节流-编码

文字-字节流-编码

来源:二三娱乐
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);
        
    }

Copyright © 2019- yule263.com 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务