6-服务器端转发和客户端重定向

image-20221116114942776

服务端转发

==request.getRequestDispatcher(“demo7”).forward(request,response);==

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
demo6
public class demo6Servlet extends HttpServlet {

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//内部转发
System.out.println("demo6");
request.getRequestDispatcher("demo7").forward(request,response);


}
}

dmeo7
public class demo7Servlet extends HttpServlet {

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//内部转发
System.out.println("demo7");


}
}

image-20221116144918845路径不发生改变

image-20221116111023245

客户端重定向

image-20221116113858712

image-20221116145113163发送改变并且有两个请求