0

我在jsp中有一个ui,有两个字段,一个是文本框,另一个是按钮。想要在不使用任何 java 脚本的情况下在纯 java 代码中单击按钮后显示带有文本框值的位置建议

我在java中使用下面的代码

System.setProperty("http.proxyHost","my proxy") ;
System.setProperty("http.proxyPort", "8080") ;

URL u = new URL("https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=geocode&language=fr&sensor=true&key=KEY_AWESOMENESS");

HttpURLConnection con = (HttpURLConnection) u.openConnection();
//
// it's not the greatest idea to use a sun.misc.* class
// Sun strongly advises not to use them since they can
// change or go away in a future release so beware.
//

di = new DataInputStream(con.getInputStream());
while(-1 != di.read(b,0,1)) {
    System.out.print(new String(b));
}

给出一些错误,例如

java.io.IOException: Server returned HTTP response code: 407 for URL: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=geocode&language=fr&sensor=true&key=KEY_AWESOMENESS"
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)

有谁能够帮我。

4

0 回答 0