resttemplate 请求方式详解

Posted ww25

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了resttemplate 请求方式详解相关的知识,希望对你有一定的参考价值。

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();

 

以上是关于resttemplate 请求方式详解的主要内容,如果未能解决你的问题,请参考以下文章

Android中的几种网络请求方式详解

resttemplate 请求方式详解

python3+requests:post请求四种传送正文方式(详解)

Postman请求方式详解

HTTP协议详解

HTTP1.1协议详解