当前位置:网站首页>数据提交类型 Request Payload 与 Form Data 的区别总结
数据提交类型 Request Payload 与 Form Data 的区别总结
2022-07-25 07:03:00 【清风细雨_林木木】
大纲
1.什么是`Request Payload`,什么是`Form Data`
2.不同的`Content-Type`对应不同的提交方式
3.总结
图形:
1.什么是Request Payload,什么是Form Data
Request Payload (http请求体模式)
Form Data (表单请求体模式)
Request Payload 对应:
Content-Type:application/json
Form Data 对应:
Content-Type: application/x-www-form-urlencoded
和
Content-Type: multipart/form-data
备注:表单(POST请求)的编码
<form action="/xxxx" method="get" enctype="application/x-www-form-urlencoded"><form action="/xxxx" method="get" enctype="multipart/form-data"><form action="/xxxx" method="get" enctype="text/plain">
| 类型 | 含义 |
|---|---|
| application/x-www-form-urlencoded | 默认编码方式, 将数据编码成键值对形式 |
| multipart/form-data | 表单文件上传 |
| text/plain | 字符串型,数据获取方式 getInputStream |
2.不同的Content-Type对应不同的提交方式
数据传输中一般类型只有3种
1.Content-Type: text/plain
2.Content-Type: application/x-www-form-urlencoded
3.Content-Type: application/json
传统
ajax请求方式Content-Type:text/plain
function submit2() {
var xhr = new XMLHttpRequest();
xhr.timeout = 3000;
var obj = {
a: 1, b: 2};
xhr.open('POST', '/');
xhr.send(obj);
}
需要通过xhr.send(JSON.stringify(obj)) 修改为字符串后进行传输。
Content-Type: text/plain
Request Payload: #字符串
axios方式请求Content-Type:application/json 和 Content-Type: application/x-www-form-urlencoded
function submit3() {
var sence1 = 'name=123&val=456';
var sence2 = {
name: 123, val: 456};
axios.post('/', sence1)
}
# 请求数据为“字符”时:
Content-Type: application/x-www-form-urlencoded
Form Data: #name=123&val=456
# 请求数据为“对象”时:
Content-Type:application/json
Request Payload: #{name:123,vla:456}
Form表单提交
<form action="/" method="POST">
<input name="name" type="text">
<input name="password" type="text">
<button>提交</button>
</form>
Content-Type: application/x-www-form-urlencoded
Form Data: # name='xxx'&password='yyy'
3.总结
Content-Type的差异
| 模式 | 类型 |
|---|---|
| ajax | Content-Type默认为 “文本” 类型 |
| form提交 | Content-Type默认为 “Form” 类型 |
| axios传递字符串 | Content-Type默认为 “Form” 类型 |
| axios传递对象 | Content-Type默认为 “JSON” 类型 |
边栏推荐
- Prevention strategy of Chang'an chain Shuanghua transaction
- vulnhub CyberSploit: 1
- [semidrive source code analysis] [drive bringup] 39 - touch panel touch screen debugging
- 【电脑讲解】去电脑维修店修电脑需要注意什么?
- A little consideration of strategic mode
- LeetCode46全排列(回溯入门)
- 列表推导式
- Will eating fermented steamed bread hurt your body
- 30 times performance improvement -- implementation of MyTT index library based on dolphin DB
- EFCore高级Saas系统下单DbContext如何支持不同数据库的迁移
猜你喜欢

knapsack problem

使用 Web API 上传和下载多个文件
![[daily question 1] 1184. Distance between bus stops](/img/36/2bbb8cc2a1fdd08070a5df7527e692.png)
[daily question 1] 1184. Distance between bus stops

Basic usage of thread class
![[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!](/img/11/24f92b4362026ec2c01492d195560b.png)
[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!

OpenAtom XuperChain 开源双周报 |2022.7.11-2022.7.22

Recycleview realizes horizontal sliding of overlapping items

Software engineering in Code: regular expression ten step clearance

Statistical learning -- naive Bayesian method

Box horse "waist cut", blame Hou Yi for talking too much?
随机推荐
The ultimate difference between MVC and three-tier architecture
Dynamic memory management
Can communication test based on STM32: turn the globe
In container multicast
2022 Tiangong cup ctf--- crypto1 WP
C control open source library: download of metroframework
Boiling short drama Jianghu: nine of the ten production teams are shooting, with a head sharing fund of more than 30million, and users are addicted to paying routines
Du Jiao sieve
CodeForces 1417B Two Arrays
Argocd user management, RBAC control, script login, APP synchronization
【每日一题】1184. 公交站间的距离
Talk about practice, do solid work, and become practical: tour the digitalized land of China
OpenAtom XuperChain 开源双周报 |2022.7.11-2022.7.22
Will eating fermented steamed bread hurt your body
Vscode saves setting configuration parameters to the difference between users and workspaces
Analysis of the calling principle of Changan chain solid smart contract
解密NumPy求解梯度的一个关键难点
GIS实战应用案例100篇(十七)-基于DEM制作三维地图
微信小程序switchTab传参以及接收参数
Rongyun launched a real-time community solution and launched "advanced players" for vertical interest social networking