阶段5 3.微服务项目【学成在线】_day04 页面静态化_14-页面静态化-数据模型-远程请求接口

如何远程请求轮播图的DataRrl


最终使用OkHttpClient

配置RestTemplate的Bean

使用RestTemplate

在Service里面注入就可以

测试类去测试RestTemplate





restTemplate里面有很多的方法

因为我们刚才写的DataUrl的接口是get的所以这里用getForEntity

responseType就是响应类型,这里我们用Map

使用getBody拿到具体的数据










 

猜你喜欢

转载自www.cnblogs.com/wangjunwei/p/11593250.html
今日推荐