java我可以使用嵌套的rest webservice或在webservice中打开链接吗
我正在尝试打开一个链接(s)从webservice可以这样做 或者我可以在webservice中调用webservice吗
@Path("/testUrl")
public class TestResource {
@GET
@Produces("text/plain")
public void callUrl() throws Exception {
open("http://www.goggle.com");
open("http://www.goggle.com");
Desktop desktop = java.awt.Desktop.getDesktop();
URI url1 = new URI("http://www.google.com");
URI url2 = new URI("http://www.yahoo.com");
desktop.browse(url1);
desktop.browse(url2);
}
private void open(String url) throws Exception {
URL siteURL = new URL(url);
HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection();
connection.setRequestMethod("GET");
connection.connect();
}
}
共 (0) 个答案