首页 > 解决方案 > 如何在 RestTemplate 参数中发送 LocalDate

问题描述

String在下面,我使用名为的参数调用了 Web 服务"samana"

String samana= "000ABC";

RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> requestEntity = new HttpEntity<String>(null, headers);

Table res = restTemplate
        .exchange("http://localhost:8090/tharindu/findAllComputers?saman=").concat(samana), HttpMethod.GET, requestEntity, Table.class)
        .getBody();

如何在 RestTemplate webservice 中传递 LocalDate 参数

LocalDate samana = LocalDate.now();

RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> requestEntity = new HttpEntity<String>(null, headers);

Table res = restTemplate
        .exchange("http://localhost:8090/tharindu/findAllComputers?saman=").concat(samana), HttpMethod.GET, requestEntity, Table.class)
        .getBody();

标签: springspring-bootspring-mvcresttemplatespring-resttemplate

解决方案


推荐阅读