如何使用Spring Boot使用API​​从Postman进行数据表单发布

时间:2018-07-13 02:36:28

标签: java api spring-boot postman

我只想像Postman一样制作数据表单,我有这样的代码

@PostMapping(value = "/current_location_all")
@ResponseBody
public JSONObject getCurrentLocationAll(Principal principal) throws Exception {
    JSONArray list = new JSONArray();
    JSONObject obj = new JSONObject();
    JSONObject obj1 = new JSONObject();

    String result = "";

    String userName = "santoso215";

    UserTBike user = userService.getUserByUsername(userName);
    Whitelist wl = whitelistService.getBikeId(userName);

    List<TBike> bike = tbikeService.getAllLocation(wl.getBikeId());
    for (int i = 0; i < bike.size(); i++) {
        obj1.put("bikeID",bike.get(i).getBikeId());
        obj1.put("imei",bike.get(i).getBikeImei());
        obj1.put("gpsTime",bike.get(i).getGpsLastUpdate());
        obj1.put("lo",bike.get(i).getBikeLongitude());
        obj1.put("la",bike.get(i).getBikeLatitude());
        obj1.put("gps_status",bike.get(i).getBikeGpsStatus());
        list.add(obj1);
    }
    obj.put("success", true);
    obj.put("data", list);



    return obj;
}

但是在邮递员中,我不使用表单数据来发送帖子。

It's not fill value from postman

我该如何填写值表单(邮递员中的表单数据)。

0 个答案:

没有答案