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

    package response;

    import java.io.IOException;
    import java.io.PrintWriter;

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

    public class ServletResponseDemo2 extends HttpServlet {
        
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //更改response的默认吗表为gbk
            response.setCharacterEncoding("gbk");
            //告诉浏览器用相同的吗表解析数据
    //        response.setHeader("Content-type", "text/html;charset=gbk");
            //sun公司提供的便捷方式,可以替换上一句代码
            response.setContentType("text/html;charset=gbk");
            String data = "中国";
            PrintWriter writer = response.getWriter();
            //writer将数据写入到response中response查找iso8859吗表。将查到的编码发给浏览器,浏览器按照自己默认的吗表解析出数据
            writer.write(data);
        }

        
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }

    }

  • 相关阅读:
    红黑树——以无厚入有间
    红黑树——依天理以神遇
    B-树 分合之道
    B-树 动机与结构
    云心出岫——Splay Tree
    双散列和再散列暨散列表总结
    开放定址法——平方探测(Quadratic Probing)
    [LeetCode 109]
    [LeetCode 110]
    [LeetCode 111]
  • 原文地址:https://www.cnblogs.com/siashan/p/3912087.html
Copyright © 2011-2022 走看看