我总是收到“连接到 ${url} 时出错”消息?
谁能告诉我我的错误?
def url = new URL("https://www.google.com")
HttpURLConnection connection = (HttpURLConnection) url.openConnection()
connection.setRequestMethod("GET")
// connection.setConnectTimeout(10000)
connection.connect()
if (connection.responseCode == 200 || connection.responseCode == 201) {
def returnMessage = connection.content
//print out the full response
println returnMessage
} else {
println "Error Connecting to " + url
}
| 错误 2012-07-05 00:04:05,950 [http-bio-8080-exec-6] 错误错误。GrailsExceptionResolver - 处理请求时发生 ConnectException:[GET] /CopperApplications/urlTracker 连接超时:连接。Stacktrace 如下:消息:连接超时:连接