我正在尝试连接其他配置文件中的端点,其定义如下:
@DeleteMapping("/persons")
public ResponseEntity<Boolean> deletePersons(@RequestBody List<Persons> persons) {
我发送了如下
resttemplate
,但它不起作用:
public ResponseEntity<Boolean> deletePersons(List<Persons> persons) {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_OCTET_STREAM));
HttpEntity<?> httpEntity = new HttpEntity<>("persons", headers);
return restTemplate.exchange(url, HttpMethod.DELETE, httpEntity, Boolean.class,
persons);
}
我收到以下错误:
没有 java.lang.String 的 HttpMessageConverter
我认为在这里你会返回一个字符串作为响应,但你想用你的函数返回一个布尔值,并且它无法将字符串转换为布尔值。
return restTemplate.exchange(url, HttpMethod.DELETE, httpEntity, Boolean.class,
persons);