get 普通请求:
restemplate.getForEntity(url,String.class).getBody();
get 导出请求:
restemplate.getForEntity(url, byte[].class);
put 请求:参数是实体类
HttpEntity<String> entity = new HttpEntity<String>(JSON.toJSON(targetDto).toString(),headers);
RestTemplate restemplate = RestTemplateHttpsUtil.restTemplate();
restemplate.exchange(url, HttpMethod.PUT,entity, Map.class);
post请求:参数是实体类
restemplate.postForEntity(url,targetDto,String.class).getBody();
原文地址:https://www.cnblogs.com/ww25/p/11351539.html
时间: 2024-10-24 23:13:49