项目经常使用传参,记录下来学习。
请求报文分类
1. url查询参数
GET http://localhost:10020/query?name=%E4%B8%BD%E4%B8%BD&age=123 HTTP/1.1
//...省略
2. url路径参数,作为url的一部分
GET http://localhost:10020/query/100 HTTP/1.1
//...省略
3. 作为请求头
GET http://localhost:10020/query HTTP/1.1
uuid: 123
age: 123
//...省略
4. 请求体:multipart/form-data
可以上传文件那种表单提交
GET http://localhost:10020/query HTTP/1.1
//...省略
content-type: multipart/form-data; boundary=--------------------------010910135056788723514580
----------------------------010910135056788723514580
Content-Disposition: form-data; name="name"
李四
----------------------------010910135056788723514580
Content-Disposition: form-data; name="age"
1213
----------------------------010910135056788723514580--
5. 请求体:application/x-www-form-urlencoded
普通的post提交,表单提交,最典型的一种
GET http://localhost:10020/query HTTP/1.1
//...省略
Content-Type: application/x-www-form-urlencoded
name=%E6%9D%8E%E5%9B%9B&age=123
6. 请求体:application/json
以json格式提交参数,这种比较适合接口调用
GET http://localhost:10020/query HTTP/1.1
//...省略
Content-Type: application/json
{"name":"李四","age":"123"}
前端常用调用方式归类
1. url查询参数
$.get("http://localhost:1