美文网首页
Postmain集成spring

Postmain集成spring

作者: 任笙_8b8c | 来源:发表于2021-02-03 09:37 被阅读0次

    Postmain集成spring测试:

    postmain传递json格式字符串的数组格式,后端接收的样列:
    1.postmain要测试需要登录的网站必须协带对应登录后获取的cookie或者token令牌放到请求头中
    系统登录后的cookie头:
    图片.png
    携带cookie头到postmian中:
    图片.png
    2.编写后端访问路径,写好接口,这里演示俩种接收方式:
    • 第一种是安map接收,所有的数据都封装到map中
    • 第二种直接用request.getParameter(data);方式接收
       @RequestMapping("/text")
       @ResponseBody
        public void aliReceive(@RequestParam Map<String, String> paramsMap) {
    
            System.out.println(paramsMap.toString());
    
            //这个是生成表格中填写的所有数据
            String data1 = request.getParameter("data");
    
            //将数据转换成字符入库表的实体类型 转成parseArray数组形式返回一个集合
            List<GovPutInfoMVO> govPutInfoMVOS = com.alibaba.fastjson.JSONObject.parseArray(data1, GovPutInfoMVO.class);
    
            System.out.println(data1);
            System.out.println(govPutInfoMVOS);
        }
    
    3.前端json示例:
    
    {"EW_ID":"1",
    "SE_ID":"1",
    "monthly":"2021-07",
    "putDate":"2021-02-11",
    "seErpNumber":"8787",
    "stuts":"",
    "telephone":"13445556666",
    "warehousePeople":"99999",
    "data":[{"breed":"N95医用级防护口罩",
    "unit":"只",
    "breedCode":"XFPYLFHWZ002",
    "specifications":"24225442542",
    "batchNumber":"1",
    "price":"1",
    "inventoryQuantity":"2",
    "contractNumber":"2",
    "isAbilityEnterprise":"1",
    "manufacturerName":"34",
    "isProvinceEnterprises":"1",
    "effectiveDate":"2021-02-19",
    "subordinateProvince":"430000",
    "index":1
    },{
    "breed":"N95医用级防护口罩",
    "unit":"只",
    "breedCode":"XFPYLFHWZ002",
    "specifications":"24225442542",
    "batchNumber":"1",
    "price":"1",
    "inventoryQuantity":"2",
    "contractNumber":"2",
    "isAbilityEnterprise":"1",
    "manufacturerName":"34",
    "isProvinceEnterprises":"1",
    "effectiveDate":"2021-02-19",
    "subordinateProvince":"430000",
    "index":2}]}
    
    
    4.Postmain传递参数示例
    图片.png

    相关文章

      网友评论

          本文标题:Postmain集成spring

          本文链接:https://www.haomeiwen.com/subject/hjaagktx.html