Struts2 type attribute (the difference between forwarding and redirection)

Details:
Forwarding: Forwarding is the behavior of the server (the URL on the browser remains unchanged) the
client browser sends an http request -> the web server accepts the request -> calls an internal method to complete the request processing and forwarding actions inside the container - —>Send the target resource to the client; here, the forwarding path must be the url under the same web container, which cannot be redirected to other web paths, and the request in its own container is passed in the middle. The path displayed in the path bar of the client's browser is still the path of the first visit, that is to say, the client does not feel that the server has forwarded it. The forwarding behavior is that the browser only makes one access request.
Redirection: client behavior (the URL on the browser changes) the
client browser sends an http request -> the web server sends a 302 status code response and the corresponding new location to the client browser after accepting it -> the client browser finds that it is 302 In response, a new http request is automatically sent, and the request url is the new location address -> the server finds resources according to this request and sends them to the client. Here location can be redirected to any URL. Since the browser reissues the request, there is no concept of request transmission. The path bar of the client's browser displays the redirected path, and the client can observe the change of the address. The redirect behavior is that the browser makes at least two access requests. The redirection
is actually the first of two requests, the client requests A, the server responds, and the response comes back, telling the browser that you should go to B. At this time, IE can see that the address has changed, and the history back button is also lit. Redirects can access resources outside of your own web application. During the redirection process, the transmitted information will be lost. Request forwarding means that the server internally transfers the processing power of a request/response to another. For the client, it only knows the A that it first requested, but does not know the intermediate B, or even C and D. The transmitted information is not lost.




Forward to action and use chain
to redirect to action and use redirectAction to
redirect:
  send request -> server operation -> respond to the request, and return a new address and response code to the browser -> the browser determines that the response is a redirect according to the response code , automatically send a new request to the server, the request address is the address returned before –> the server runs –> responds to the request to the browser
Forwarding :
  send the request –> the server runs –> reset the request, such as through request.setAttribute( name, value)–>According to the forwarded address, get the web page of the address–>respond to the request to the browser

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325904132&siteId=291194637