大佬教程收集整理的这篇文章主要介绍了使用 ResponseEntity 从另一个 API 中提取信息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
websites_enable_app_service_storage
@H_772_2@API2 服务private static List<String> getData(int attribute1){
//A pIEce of code that extracts data from the database based on the attribute1 and store the information in a res object<br>
return res;
}
@H_772_2@我是否需要更改 API1 服务函数的返回类型private static List getData(int attribute1) {
String uri = "localhost:9191/getData/" + attribute1;
private RestTemplate restTemplate = new RestTemplate();
try {
List res = restTemplate.getForObject(uri,List.class);
return res;
} catch(RestClientexception rcE) {
// Here you'll handle the exception
}
}
@H_772_2@另外,请注意 RestClientexception 有 3 个直接子类:resourceAccessException、RestClientResponseException 和 UnknownContentTypeException。您可以捕获其中的每一个,而不是捕获 RestClientexception,这样您就可以用不同的方式处理它们。以上是大佬教程为你收集整理的使用 ResponseEntity 从另一个 API 中提取信息全部内容,希望文章能够帮你解决使用 ResponseEntity 从另一个 API 中提取信息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。