Forward&Redirect

来源:互联网 发布:js img onload 编辑:程序博客网 时间:2024/05/29 07:13

forword(转发):

1.服务器端跳转(客户端只请求一次);

2.在访问时URL不会转变;

3.在服务器端直接跳转到index.jsp。

4.代码实现:request.getRequestDispatcher("index.jsp").forward(request, response);


Redirect(重定向):

1.客户端跳转(客户端需请求两次);

2.在访问时URL会转变;

3.在服务器端反馈给客户要访问index,然后客户端跳转到index.jsp。

4.代码实现: //response.sendRedirect("index.jsp");

response.sendRedirect("https://www.baidu.com/");


0 0
原创粉丝点击