2012-07-06 102 views
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" 
} 
+0

哪里?在一个页面?你的问题有点含糊。请提供更多关于环境的细节。 – mschonaker 2012-07-06 03:12:54

+0

我的意思是我现在得到这个println的东西来检查它的工作与否。现在我想在grails list.gsp页面中填充这些信息 – sam1132 2012-07-06 03:21:08

回答