所以我做了一個小程序,並將其發送POST方法的網站,然後打印出響應的HttpResponse的顯示內容,我可以顯示在Web瀏覽器的響應?爪哇 - 在Web瀏覽器
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
if (line.startsWith("Auth=")) {
String key = line.substring(5);
// Do something with the key
}
}
} catch (IOException e) {
e.printStackTrace();
}
在調試器中打印整個頁面,我可以在瀏覽器中顯示嗎?
我使用Apache的HttpClient的。
是否有可能響應某種方式轉換爲URI,然後使用java.awt.Desktop.getDesktop().browse(response);
哦,這是多麼可憐!我使用POST。 – 2013-03-17 20:34:21
因此無法將響應轉換爲URI? – 2013-03-17 20:35:15
響應不是URI - 響應是內容(文本,html,xml,json等)。可以將請求發送到您的servlet的URI。由於您使用POST,因此您需要使用POST方法的HTTP表單與您的servlet的URL。 – 2013-03-18 08:58:20