当前位置:   article > 正文

resttemplate 请求重试_通过restTemplate发送请求,特定类型参数无法被解析的问题...

resttemplate 无法在文件系统中解析以检查其内容长度

客户端通过RestTemplate发送请求,requestBody是一个复杂数据类型,通过嵌套多层MultiValueMap的方式组合服务端需要的数据类型。

HttpEntity requestBody = generateAddAllRequestBody(strategyJobs);

ResponseEntity responseEntity = this.restTemplate.postForEntity(jobAddAllUrl, requestBody, String.class); private HttpEntity generateAddAllRequestBody(List strategyJobs) {

HttpHeaders headers = new HttpHeaders();

headers.setContentType(MediaType.MULTIPART_FORM_DATA);

MultiValueMap outerMap = new LinkedMultiValueMap<>();

for(StrategyJob strategyJob : strategyJobs) {

MultiValueMap map = new LinkedMultiValueMap();

map.add("jobGroup",strategyJob.getGroup());

map.add("jobDesc", strategyJob.getJobDesc());

map.add("executorRouteStrategy", "FIRST");

map.add("cronGen_display", strategyJob.getCron());

map.add("jobCron", strategyJob.getCron());

map.add("glueType", "BEAN");

map.add("executorHandler", strategyJob.getExecutorHandler());

map.add("executorBlockStrategy", "SERIAL_EXECUTION");

map.add("childJobId", "");

map.add("executorTimeout", 0);

map.add("executorFailRetryCount", 0);

map.add("author", strategyJob.getCreator());

map.add("alarmEmail", "");

map.add("executorParam", strategyJob.getStrategyId());

map.add("glueRemark", "GLUE代码初始化");

map.add("glueSource", "");

map.add("triggerStatus", 1);

if (strategyJob.getId() != null) {

map.add("id", strategyJob.getId());

}

outerMap.add(strategyJob.getKey(), map);

}

HttpEntity requestBody = new HttpEntity(outerMap, headers);

return requestBody;

}

服务端接收请求的时候,只能解析第一

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

闽ICP备14008679号