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); }
原文地址:https://www.cnblogs.com/zhai1997/p/11483234.html
时间: 2024-10-13 18:40:52