zoukankan      html  css  js  c++  java
  • 关于responseHeader的一些基础设置

      1.关于响应头的一些基础设置

      //设置相应头     
    response.addHeader("name","zhangsan"); response.addIntHeader("age",28); response.addDateHeader("brithday", date.getTime()); response.addHeader("name","lisi");

          

          2.set设置  覆盖前面相同的设置

    response.setHeader("name", "wangwu");

         

        3.结果

    4.完整代码

    package com.hdh.header;
    
    import java.io.IOException;
    import java.sql.Date;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class HeaderServlet extends HttpServlet {
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            Date date=new Date(0);
            //设置相应头
            response.addHeader("name","zhangsan");
            response.addIntHeader("age",28);
            response.addDateHeader("brithday", date.getTime());
            response.addHeader("name","lisi");
            
            //set设置  覆盖前面想同的设置
            response.setHeader("name", "wangwu");
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            doGet(request, response);
        }
    
    }
  • 相关阅读:
    CentOS 7.x 二进制方式安装mysql5.7.24
    Java集合框架学习总结
    deque 归纳
    KMP学习笔记
    luogu 3393 逃离僵尸岛
    luogu 1280 尼克的任务
    HDU4871 Shortest-path tree(点分治)
    BZOJ4399 魔法少女LJJ
    BZOJ4771 七彩树
    (BUILDER)建造者与(FACTORY)工厂模式 的比较
  • 原文地址:https://www.cnblogs.com/asndxj/p/9821475.html
Copyright © 2011-2022 走看看