HTML(11)GET请求和POST请求

2020-10-23

GET请求

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提交数据</title>
</head>
<body>
    <!-- form表单提供了GET,和POST请求 -->
    <form action="http://www.baidu.com" method="GET">
        <p>
            <input type="text" name="login">
        </p>
        <p>
            <input type="password" name="pass">
        </p>
        <p>
            <input type="submit">
        </p>
    </form>
</body>
</html>

我们可以看到,GET请求的数据已经提交到了地址栏

image.png

image.png

我们换一种请求方式POST,会发现他提交的form-data数据

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提交数据</title>
</head>
<body>
    <!-- form表单提供了GET,和POST请求 -->
    <form action="http://www.baidu.com" method="POST">
        <p>
            <input type="text" name="login">
        </p>
        <p>
            <input type="password" name="pass">
        </p>
        <p>
            <input type="submit">
        </p>
    </form>
</body>
</html>

image.png

image.png

GET请求和POST请求的区别

  • GET请求通常表示获取数据
  • POST请求通常表示提交数据
  • GET请求发送的数据都会写在地址栏上,用户可见
  • POST请求发送的数据用户不可见
  • GET请求不能提交大量数据,但POST可以,所以不要混用

标题:HTML(11)GET请求和POST请求
作者:张范
地址:http://60.204.174.80/articles/2020/10/23/1603421926914.html