0
我有一個域名,如URL,lastModified等現在我想查看我從這段代碼到列表頁面的信息。我該怎麼辦THT在瀏覽器上查看數據
def url = new URL("http://www.google.com")
HttpURLConnection connection = (HttpURLConnection)url.openConnection()
// long contentLength = Long.parseLong(connection.getHeaderField("Content-Length"));
connection.setRequestMethod("GET")
connection.connect()
connection.getURL()
println("Date: " + new Date(connection.getDate()))
println("LastModified Date:" + new Date(connection.getLastModified()))
if (connection.responseCode == 200 || connection.responseCode == 201){
def returnMessage = connection.content
//print out the full response
println "${returnMessage}";
System.out.println(connection.getURL());
} else {
println "Error Connecting to " + url
println "Couldn't connect to url"
}
哪裏?在一個頁面?你的問題有點含糊。請提供更多關於環境的細節。 – mschonaker 2012-07-06 03:12:54
我的意思是我現在得到這個println的東西來檢查它的工作與否。現在我想在grails list.gsp頁面中填充這些信息 – sam1132 2012-07-06 03:21:08