目录
application/x-www-form-urlencoded
application/x-www-form-urlencoded
请求头中有content-type数据:
一般在表单中填写enctype:
其中enctype有如下的几种:
1. application/x-www-form-urlencoded
2. multipart/form-data
3. text/plain
这个是浏览器自动生成的数据请求!
如下的HTML:
<html>
<head>
<title>优快云 IT1995</title>
</head>
<body>
<form action="/form" method="POST" enctype="application/x-www-form-urlencoded">
<input type="text" name="name">
<input type="password" name="password">
<input type="submit">
</form>
</body>
</html>
运行截图如下:
填好表单后:
这里把这两个都勾上:
点击提交:
可以看到当Content-Type:application/x-www-form-urlencoded时,form表单数据如下:
点击原始后:
这个application/x-www-form-urlencoded只是把GET方法放到url中的放到body里面罢了!
multipart/form-data
把enctype修改为:multipart/form-data后,源码如下:
<html>
<head>
<title>优快云 IT1995</title>
</head>
<body>
<form action="/form" method="POST" enctype="multipart/form-data">
<input type="text" name="name">
<input type="password" name="password">
<input type="submit">
</form>
</body>
</html>
再次提交表单看看:
发现浏览器默认加了一个boundary,然后在Request Payload里面,以这个为边界进行划分,并且还带上了表单的name。突然间感觉,又掉巧妙啊!
text/plain
把enctype修改如下:text/plain
源码如下:
<html>
<head>
<title>优快云 IT1995</title>
</head>
<body>
<form action="/form" method="POST" enctype="text/plain">
<input type="text" name="name">
<input type="password" name="password">
<input type="submit">
</form>
</body>
</html>
提交表单后:
从中可以知道这个text/plain还是很常规的。