简体   繁体   English

forward和sendRedirect之间的区别

[英]Difference between forward and 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;

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? 我现在确信第一个语句是错误的,因为使用请求肯定是向前传递值的方法,但我对sendRedirect感到困惑,在这个意义上它是否正确? Could experts help? 专家可以帮忙吗? Thanks. 谢谢。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM