Servlet跳转

服务端跳转与客户端跳转图示:

Servlet跳转


1.在Servlet中进行服务端跳转的方式:

request.getRequestDispatcher("success.html").forward(request, response);
服务端跳转可以看到浏览器的地址依然是/login 路径,并不会变成success.html

 

2.在Servlet中进行客户端跳转的方式:

response.sendRedirect("fail.html");

浏览器地址会发生变化