-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestDemo03.java
More file actions
34 lines (29 loc) · 1.03 KB
/
Copy pathRequestDemo03.java
File metadata and controls
34 lines (29 loc) · 1.03 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
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.IOException;
/**
* @author : CodeWater
* @create :2022-03-13-16:20
* @Function Description :
*/
@WebServlet("/requestDemo03")
public class RequestDemo03 extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//获取请求头数据
String agent = req.getHeader("user-agent");
//先写edg,后写Chrome。因为edge里面内容也是有chrom
if (agent.contains("Edg")) {
System.out.println("Edge来了");
} else if (agent.contains("chrome")) {
System.out.println("谷歌来了");
}
}
}