一 getForEntity系列函数
函数原型:
1 getForEntity(String url,Class responseType,Object ... urlVariables)
2 getForEntity(String url,Class responseType,Map urlVariables)
3 getForEntity(URI url,Class responseType)
实例:
public String hello() {
StringBuilder result = new StringBuilder();
// GET
//方式一
result.append(restTemplate.getForEntity("http://HELLO-SERVICE/hello", String.class).getBody()).append("<br>");
//方式二
result.append(restTemplate.getForEntity("http://HELLO-SERVICE/hello1?name={1}", String.class, "didi").getBody()).append("<br>");
//方式三
Map<String, String> params = new HashMap<>();
params.put("name", "dada");
result.append(restTemplate.getForEntity("http://HELLO-SERVICE/hello1?name={name}", String.class, params).getBody()).app