The difference between forwarding and redirection in servlet

redirect

If the method redirects to another url, the method return value is "redirect: url path"

Use redirect to redirect, request data cannot be shared, and the URL address bar will change.

The url address changes as follows:
Insert picture description here

Insert picture description here
After submission
Insert picture description here

forward

Use forward to forward the request, request data can be shared, and the URL address bar will not change.
The return value of the method is "forward: url path"

The url address changes as follows:
Insert picture description here

Insert picture description here
After submission
Insert picture description here

Guess you like

Origin blog.csdn.net/Hambur_/article/details/110657916