java servlet:servlet中send redirect和forward之间的区别

编程入门 行业动态 更新时间:2024-10-07 12:23:46
本文介绍了java servlet:servlet中send redirect和forward之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用servlet有两种方法重定向和转发两者都是发送请求到同一页但它们之间有什么区别。任何想法

I am using servlet there is two method redirect and forward both are send request to the same page but what is the difference between them.any idea

推荐答案

  • 重定向 - 它使用浏览器重定向。它发送一个代码为3xx的http响应(查看维基百科),然后浏览器发出另一个请求新页面

    • redirect - it uses a browser redirect. It sends an http response with code 3xx (see wikipedia), and then the browser makes another request to the new page

      forward-forward是servlet容器的内部。浏览器永远不会理解页面已更改。因此,URL不会更改(例如重定向),并且您在新页面中也有相同的请求。

      forward - forward is internal for the servlet container. The browser never understands that the page has changed. Hence the URL doesn't change (like with redirect), and you have the same request in the new page as well.

更多推荐

java servlet:servlet中send redirect和forward之间的区别

本文发布于:2023-11-25 06:21:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   servlet   java   redirect   send

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!