response对响应的设置
Posted zhai1997
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了response对响应的设置相关的知识,希望对你有一定的参考价值。
1、response对象设置响应行状态码:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException response.setStatus(404);
2、response对象添加响应头:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
Date date=new Date(121344444);
response.addHeader("zzz","I love JAVA.");
response.addIntHeader("myself",22);
response.addDateHeader("Time:",date.getTime());
3、response对象设置响应头:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException Date date=new Date(121344444); response.addHeader("zzz","I love JAVA."); response.addIntHeader("myself",22); response.addDateHeader("Time:",date.getTime()); response.setIntHeader("myself",23);
以上是关于response对响应的设置的主要内容,如果未能解决你的问题,请参考以下文章