一、Get 服務(wù)消費(fèi)
(1) getForEntity
1. URI restTemplate
UriComponents components = UriComponentsBuilder.fromUriString("http://HELLO-SERVICE/hello?name={name}").build().expand("grandkai").encode("utf-8");
URI uri = components.toUri();
ResponseEntity<String> entity = restTemplate.getForEntity(uri, String.class);
2. restTemplate.getForEntity(String url, Class responseType, Map urlVariables)
Map<String, String> param = new HashMap<>();
param.put("name", "GrandKai");
restTemplate.getForEntity("http://HELLO-SERVICE/hello?name={name}", String.class, param).getBody();
3. restTemplate.getForEntity(String url, Class responseType, String... urlVariables)
return restTemplate.getForEntity("http://HELLO-SERVICE/hello?name={1}", String.class, "grandkai").getBody();
(2) getForObject
重載方法同 getForEntity 是對它的進(jìn)一步封裝,只關(guān)心 body 內(nèi)容
二、Post 請求
1. postForEntity
2. postForObject
3. postForLocation
三、Put 請求
四、Delete 請求
Ribbon
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 以前,當(dāng)別人夸我脾氣好時(shí),我總暗自高興,認(rèn)為自己的溝通能力還不錯(cuò)??稍介L大越發(fā)現(xiàn),脾氣好≠會溝通,因?yàn)樗^的“好”...
- 轉(zhuǎn)載:http://blog.csdn.net/tskyfree/article/details/8121915 ...
- 城里很熱心很方,就想出來納個(gè)涼,于是決定去云南,嘿嘿一點(diǎn)不草率。 到達(dá)普者黑已經(jīng)是傍晚,找好客棧吃好飯就近逛了逛,...
- 語文作業(yè): 把今天學(xué)的復(fù)韻母iu各寫兩行,每行后四個(gè)帶聲調(diào),拼讀各寫兩遍,兒歌和拼讀讀一讀。 數(shù)學(xué)作業(yè): 預(yù)備數(shù)學(xué)...