重定向(redirect)和转发(forward)区别

来源:互联网 发布:永恒之塔女性捏脸数据 编辑:程序博客网 时间:2024/05/17 01:20
forward方式:request.getRequestDispatcher("/somePage.jsp").forwardrequest, response);    redirect方式:response.sendRedirect("/somePage.jsp");
<table border="1" cellspacing="1" cellpadding="1" width="874" style="width: 874px; height: 146px;"><tbody><tr><td>forward</td><td>redirect</td></tr><tr><td>执行forward后,网页地址依旧是上次请求的</td><td>生成新请求,地址改变</td></tr><tr><td><pre id="answer-content-963981700" class="answer-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word;">之前请求的参数都在,转发页面和转发到的页面可以共享request里面的数据
全丢失
<span style="color: rgb(51, 51, 51); widows: 2; font-size: 14px; line-height: 26px; font-family: Arial; white-space: normal; orphans: 2; background-color: rgb(255, 255, 255);"></span><pre id="answer-content-963981700" class="answer-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word;">一般用于用户登陆的时候,根据角色转发到相应的模块.
一般用于用户注销登陆时返回主页面和跳转到其它的网站等.
                                             
0 0