我是网络服务的初学者,我有一个设计问题,以便拥有一个高效的代码。我在我的后端例如这样的资源:
@RequestMapping(value = "/app", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getAppList() {
try {
Assert.notNull(applicationService, "applicationService is null");
System.out.println("getAppList()");
List<AppTransferData> list = applicationService.getApplicationList();
System.out.println(list);
Assert.notNull(list, "list is null");
Collections.sort(list);
return new ResponseEntity<>(list, HttpStatus.OK);
}
catch (Exception e) {
System.out.println(e);
return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
/* adding HTTP Get request here?? */
}
我想在此资源上添加其他URL域上的http GET请求。像这样的东西
URL url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
...
我把它放在捕获之后还是没有?
非常感谢