入门servlet:request获取请求体数据

 1 @WebServlet("/RequestDemo5")
 2 public class RequestDemo5 extends HttpServlet {
 3     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 4         //获取请求消息体--请求参数
 5 
 6         //1.获取字符流
 7         BufferedReader br = request.getReader();
 8         //2.读取数据
 9         String line = null;
10         while((line = br.readLine()) != null){
11             System.out.println(line);
12         }
13     }
14 
15     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
16 
17     }
18 }
原文地址:https://www.cnblogs.com/flypig666/p/11480376.html