一、
1)、response获得的流不需要手动关闭,Tomcat容器会帮你自动关闭
2)、getWriter和getOutputStream不能同时调用
//error
package com.itheima.content;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class ErrorServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.getWriter();//这两行代码先后顺序一变化,页面的提示也会相应变化response.getOutputStream();}public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet(request, response);}
}
会报错:
3)、response有缓冲区,并且缓冲区有大小默认是8K