java servlet:servlet中send redirect和forward之间的区别 [英] java servlet: difference between send redirect and forward in servlets

查看:154
本文介绍了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之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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