默认的header是类似这样的
User-Agent: Fiddler
Host: localhost
Content-Length: 34
只需要改成这样的
User-Agent: Fiddler
Content-Type: application/x-www-form-urlencoded
Host: localhost
Content-Length: 34
然后我们在request body里都这么写post串,服务端就可以接收post值了
city='dfdafdsfsaf'&mm="1232323123"
神马,还想传JSON?,so easy,把header里改成这样
User-Agent: Fiddler
Content-Type: application/json
Host: localhostrequset body里就这么写
{
"city": "dfdafdsfsaf",
"mm": "1232323123"
}
在Http中,POST参数的请求格式是由Content-type选项控制的。比较常见两种Content-type选项和数据格式我用下表列出:
content-type 参数格式
application/x-www-form-urlencoded info=10001030A&itme=wwwdn_06RMB
application/json {"info":"10001030A","item":"wwwdn_06RMB"}