• 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);
        }

    }

  • 相关阅读:
    shell中test命令方法详解
    Linux 查看端口使用情况
    jboss 报错处理及端口修改
    jboss的使用和安装
    python 关于列表的增删改查及个别的命令
    Cisco Cat4500系列High CPU故障步骤摘要
    Services: ARP Caching
    Passive Client Feature
    BGP前缀过滤(正则表达式)
    Cisco Spectrum Expert(Wave2 AP)
  • 原文地址:https://www.cnblogs.com/siashan/p/3911998.html
Copyright © 2020-2023  润新知