我想通过 Spring RestTemplate 发送一个 HTTP PATCH 请求,其中包含由以下对象表示的操作数组:
@Data
@AllArgsConstructor
public class JsonOperation {
private String op;
private String path;
private String value;
}
考虑以下代码:
List<JsonOperation> operations = new ArrayList<>();
operations.add(new JsonOperation("replace", "/path1", "value1"));
operations.add(new JsonOperation("replace", "/path2", "value2"));
operations.add(new JsonOperation("replace", "/path3", "value3"));
是否可以按如下方式使用 restTemplate 进行请求?
restTemplate.patchForObject(url+"/toPatch/"+toPatchId, operations, ResponseEntity.class);