当前位置:   article > 正文

Java RestTemplate post请求传递对象参数_httpentity不传数组,传对象

httpentity不传数组,传对象
通过exchange发送Post请求并设置header和请求体body
  1. LoginParam param = LoginParam.builder().loginName(loginName).password(password).build();
  2. HttpHeaders httpHeaders = new HttpHeaders();
  3. httpHeaders.add("Content-Type", "application/json");
  4. HttpEntity<String> httpEntity = new HttpEntity<>(JSON.toJSONString(param), httpHeaders);
  5. String url = DustConstant.DUST_URL.concat(DustConstant.LOGIN);
  6. ResponseEntity<JSONObject> responseEntity = restTemplate.exchange(url,
  7. HttpMethod.POST, httpEntity, JSONObject.class);

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/302799
推荐阅读
相关标签
  

闽ICP备14008679号