我正在使用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之间的区别
发布评论