-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestDemo05.java
More file actions
35 lines (29 loc) · 1.06 KB
/
Copy pathRequestDemo05.java
File metadata and controls
35 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package request;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
/**
* @author : CodeWater
* @create :2022-03-13-16:20
* @Function Description :
*/
@WebServlet("/requestDemo05")
public class RequestDemo05 extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//获取请求消息体-请求参数(只有post才有消息体,不要写到get里面去)
BufferedReader br = req.getReader();
String line = null;
while ((line = br.readLine()) != null) {
//打印了从regist提交的数据username=CodeWater&password=fddfd
System.out.println(line);
}
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
}
}