我在这里遇到了一个奇怪的问题,
当我从 Web 浏览器或 java 命令行在 url 下面运行时
我得到以下结果。
{
"destination_addresses" : [ "Storås Industrigata 20, 424 69
Angered, Sweden" ],
"origin_addresses" : [ "Gothenburg, Sweden" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "10.4 km",
"value" : 10388
},
"duration" : {
"text" : "15 mins",
"value" : 924
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
但是当我从 glassfish 服务器运行相同的 url 时,我的意思是从表单提交发送一个 http 请求,我得到以下奇怪的响应
{ "destination_addresses" : [ "" ],
"origin_addresses" : [ "Gothenburg, Sweden" ],
"rows" : [
{
"elements" : [
{
"status" : "NOT_FOUND"
}
]
}
],
"status" : "OK"
}
请不要在这种情况下destination_addresses 为空,状态为NOT_FOUND。
我用来获得响应的 Java 代码是
private String getResponse(String URL) throws Exception {
InputStream stream = new URL(URL).openStream();
byte[] array = new byte[stream.available()];
stream.read(array);
return new String(array);
}
请指导我解决这个问题,
谢谢....