Request difference and works forwarding and redirection

In the previous article, we use the request forwarding and redirection, but I just know how They are used, there are some differences which, if you ask me why, I was ignorant of the force, now for everyone to sort out their differences and use, and finally to explain why.
First on a chestnut.

Redirect:
Here Insert Picture Description
Surely we have used, directly main.html will be redirected to the page, and redirect is a secondary forward, not with the original parameters, the address bar will change.
Why is this? Let's analyze it works.

HTTP protocol specifies a redirection mechanism to redirect the operation process is as follows:
(1) the user in the browser to enter a specific URL, the request to access a server-side components.
Component (2) the server returns a status code in response to the results of 302, meaning that the response result is:
Let browser then requests access to another Web component, a URL to another Web component in response to the results. Another Web Components possible on the same Web server, there may no longer be on the same Web server.
(3) When the browser receives such a response result, and then immediately and automatically requesting access to another Web component.
(4) the browser receives the response result of another Web component.

This is why there is reason redirected the above-mentioned characteristics. Note the following points: a source and destination components do not share a ServletRequest object, and therefore do not share request to share data within the range.
If you start with "/", it said the current server-relative URL root path, if the http: // at the beginning, represents a complete URL.

Here Insert Picture Description
We then forward the request to analyze the
first on the map
Here Insert Picture Description
Let's talk about its features and usage analysis it works again
request the same forwarding address bar, you can share data request domain. Send only one request, path path / after either an absolute path or a relative path. This is basically a commonly used features. Let's look at it workflows.

First on a map it, more clear
Here Insert Picture Description
our client sends a request, only the target component in response to the results obtained will be returned to the client. That server will automatically process the request back to us. So whether an object with a request to forward many times, still.

If you ask someone I think you should come up now to answer it.

Published 37 original articles · won praise 8 · views 5250

Guess you like

Origin blog.csdn.net/weixin_42714605/article/details/104816172