码迷,mamicode.com
首页 > 其他好文 > 详细

关于responseHeader的一些基础设置

时间:2018-10-20 14:56:53      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:time()   ima   extends   row   head   exception   height   bsp   覆盖   

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

}

 

关于responseHeader的一些基础设置

标签:time()   ima   extends   row   head   exception   height   bsp   覆盖   

原文地址:https://www.cnblogs.com/asndxj/p/9821475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!