fiddler发送post请求

简介:

v1.指定为 post 请求,输入 url

  Content-Type: application/x-www-form-urlencoded;charset=utf-8

  request body中的参数格式:userName=adminicxp&userPassword=123qwe!@#

   这种方式可以用 request.getParameter的方式来获得。

v2.指定为 post 请求,输入 url

  Content-Type: application/json; charset=utf-8

  request body中的参数格式:

{
    "userName": "adminicxp",
    "userPassword": "123qwe!@#",
    "sysId": "xxx"
}

 

  这种方式通过如下方式获得:

复制代码
    @RequestMapping("/xxx")  
    @ResponseBody  
    public String xxx(HttpServletRequest request) throws IOException {  
  
        String jsonString = getBodyString(request.getReader());  
  
        JSONObject jbJsonObject = new JSONObject().fromObject(jsonString);  
  
        User user = (User) JSONObject.toBean(jbJsonObject, User.class);  
        System.out.println(jbJsonObject);  
        System.out.println("id:" + user.getUserName());return null;  
  
    }  
  
    @RequestMapping("/xxx2")  
    @ResponseBody  
    public String xxx2(User user) throws IOException {  
  
        System.out.println("---------------");  
        System.out.println(user.getUserName());  
        System.out.println(user.getPassWord());  
        System.out.println("---------------");  
  
        if (true) {  
            return "success";  
        } else {  
            return "fail";  
        }  
  
    }  

  public String getBodyString(BufferedReader br) { 
String inputLine; 
String str = ""; 
try { 
while ((inputLine = br.readLine()) != null) { 
str += inputLine; 

br.close(); 
} catch (IOException e) { 
System.out.println("IOException: " + e); 

return str; 
}

 
复制代码

v 3.post数组

  方式1:

  springmvc 后台java代码

@RequestBody Map<String, List<String>> param

List<String> ids = param.get("ids");

  fiddler 请求

Content-Type指定为 application/json

RequestBody格式:{"ids":["first0001company", "xxx4234324"]}

 

  方式2:

  springmvc 后台java代码

@RequestParam List<String> ids;

或者 @RequestParam String[] ids;

  fiddler 请求

Content-Type指定为 application/x-www-form-urlencoded

RequestBody格式:ids=first0001company&ids=xxx4234324









本文转自 小眼儿 博客园博客,原文链接:http://www.cnblogs.com/hujunzheng/p/6178049.html,如需转载请自行联系原作者
目录
相关文章
|
JavaScript
Axios发送post请求下载文件
发送post请求下载文件 先说一下背景:这是一个以vue作为框架并用Axios来发送http请求的项目。我想要实现用axios来发送post请求,然后服务器会返回的response是一个文件流,我希望能将这个文件流写入excel,从而实现该excel文件的下载。
8225 0
|
数据安全/隐私保护
fiddler抓包-查看get与post请求参数
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34173549/article/details/81566563 Fiddler抓包3-查看get与post请求 前言 前面两篇关于Fiddler抓包的一些基本配置,配置完之后就可以抓到我们想要的数据了,接下来就是如何去分析这些数据。
6478 0
|
4月前
|
JSON 安全 程序员
为什么POST请求会发送两次请求?
为什么POST请求会发送两次请求?
129 0
|
6月前
|
JSON API 数据安全/隐私保护
CURL 发送POST请求
CURL 发送POST请求
|
6月前
|
JSON 测试技术 API
使用Postman发送POST请求的指南
本文介绍了如何使用Postman发送POST请求进行接口测试。关键步骤包括:创建新请求,设置请求类型为POST,输入URL,添加请求头如`Content-Type: application/json`,在Body中选择raw输入JSON数据,然后发送请求并检查响应。示例展示了向用户注册接口发送数据的过程。掌握这些技能有助于高效测试API。
|
7月前
|
Web App开发 JSON 网络安全
CURL发送POST请求
CURL发送POST请求
288 0
|
JavaScript
Fiddler 使用fiddler发送捕获的请求及模拟服务器返回
Fiddler 使用fiddler发送捕获的请求及模拟服务器返回
160 0
|
前端开发 测试技术 API
前端 Fiddler 抓包修改请求响应结果
实际前端开发中,对接线上发布的后端接口,由于业务比较复杂,也设计到以前的库表,开发过程经常会出现部分页面数据不完整,无法对接整个流程,日常前端开发也有其他方式实现功能测试验证。
288 0
前端 Fiddler 抓包修改请求响应结果
|
前端开发 安全 小程序
|
JSON Java 数据格式
跨域发送HTTP请求详解
    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥-------------         本篇博客讲述几种跨域发HTTP请求的几种方法,POST请求,GET请求 目录: 一,采用JsonP的方式(只能是GET) 二,采用CROS的方式(需要在接收的一...
1389 0