zoukankan      html  css  js  c++  java
  • servletResponse outputStream输出数据

    package response;

    import java.io.IOException;
    import java.io.OutputStream;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class ResponseDemo1 extends HttpServlet {
        //程序用什么吗表输出,就控制浏览器用什么吗表打开
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //控制浏览器用什么吗表打开
        //    response.setHeader("Content-type", "text/html;charset=gbk");
            String data = "中国";
            OutputStream out = response.getOutputStream();
            //用html技术中的<meta>标签模拟一个http响应头。来控制浏览器的行为
            out.write("<meta http-equiv='content-type' content='text/html;charset=gbk'>".getBytes());
            //控制程序一什么吗表输出
            out.write(data.getBytes("gbk"));
            
        }
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }

    }

  • 相关阅读:
    zhuanzai
    安装 Python
    解决删除/升级Python导致Ubuuntu无法进入桌面的问题
    硬盘安装ubuntu120.04分区方案
    ping: sendto: Network is unreachable
    电脑系统右键反应很慢问题
    安装Ubuntu下的开发工具
    设置文件夹为超级权限
    Ubuntu12.04配置静态ip地址
    马拉车算法
  • 原文地址:https://www.cnblogs.com/siashan/p/3911998.html
Copyright © 2011-2022 走看看