0%

RestTemplate

定义:访问第三方RESTful接口的网络请求框架

使用方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
** 将访问的页面变为String
**/
@RestController
public ClassRestController(){
@GetMapping("/testRest")
public String testRest(){
RestTemplate restTemplate = new RestTemplate();
return restTemplate.getForObject("http..",String.class);
}

}

//可以自动变为对象
User user = restTemplate.getForObject("www....",User.class);

Welcome to my other publishing channels