重定向流程

点击添加按钮添加一个新的todo的时候, 程序的流程图如下:

  1.  浏览器提交一个表单给服务器(发送POST 请求)

POST /todo/add HTTP/1.1

Content-Type: application/x-www-form-urlencoded

title = aaa

  2. 服务器解析出表单 302 中的地址, 自动发送一条新的数据, 并返回 302响应

HTTP/1.1 302 REDIRECT

Location: /todo

  3. 浏览器根据 302 中的地址, 自动发送一条性的 GET 请求

GET /todo HTTP/1/1

Host: ...

  4. 服务器给浏览器一个新的页面响应

HTTP/1.1 200 OK

Content-Type: text/html

Content-Length: ...

<html>

  ...

</html>

  5, 浏览器把新的页面显示出来

原文地址:https://www.cnblogs.com/cuzz/p/7965591.html