zoukankan      html  css  js  c++  java
  • 发送post请求,回调时通过url传参

    发送post请求,通过回调获取相应参数;在发送的url中添加参数,通过回调,获取其相应的参数值:

    eg:

    1、快递100发送post请求,进行订阅:

    public class ExpressRegisterServiceImpl {

    // 回调接口的地址
    private static final String CALLBACKURL = "http://127.0.0.1/api/v2/expresscallback/kuaidi100/expressNotify";

    public boolean registerToExpress100(ExpressOrderMapping expressOrderMapping) {

    String mURL = CALLBACKURL + "?mappingid=" + expressOrderMapping.getId();//url获取参数
    taskRequest.getParameters().put("callbackurl", mURL);

    // create Map
    Map<String, String> p = new HashMap<String, String>();
    p.put("schema", schema);
    p.put("param", JacksonHelper.toJSON(taskRequest));

    String ret = HttpUtil.post(url, p);//发送post请求

    }

    }

    2、订阅回调,获取url传参:

    @RestController
    @RequestMapping("api")
    public class ExpressCallbackController {

    @RequestMapping(value = "/v2/expresscallback/kuaidi100/expressNotify", method = RequestMethod.POST)
    public Object expressNotify(HttpServletRequest request, HttpServletResponse response) {

    String mappingid = request.getParameter("mappingid");

    String content = request.getParameter("param");

    }

    }

    3、通过postman验证:

  • 相关阅读:
    第八章 多线程编程
    Linked List Cycle II
    Swap Nodes in Pairs
    Container With Most Water
    Best Time to Buy and Sell Stock III
    Best Time to Buy and Sell Stock II
    Linked List Cycle
    4Sum
    3Sum
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/qqzhulu/p/10363623.html
Copyright © 2011-2022 走看看