转发和sendRedirect之间的区别 [英] Difference between forward and sendRedirect

查看:135
本文介绍了转发和sendRedirect之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络上的一个采访问题中遇到了这两个声明:

I have come across these two statements on an interview question on the web:

 1.forward causes object stored in request as attributes to be lost;
 2.sendRedirect causes object stored in request as attributes to be lost;

我现在确信第一条语句是错误的,因为使用请求肯定是正向传递值的工作方式,但是我对sendRedirect感到困惑,从这个意义上说这是正确的吗?专家可以帮忙吗?谢谢.

I am now confident that the first statement is wrong since using request is definitely how forward works to pass values, but I am confused about the sendRedirect one, is it correct in this sense? Could experts help? Thanks.

推荐答案

forward发生在服务器端不同,sendRedirect导致浏览器向重定向位置发起新请求,这意味着第二条语句是真的.

Unlike forward which happens on the server-side, sendRedirect causes the browser to initiate a new request to the redirect location, which means the second statement is true.

这篇关于转发和sendRedirect之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆