1
我使用HttpURLConnection
連接到網站並收到ResponseCode=404 (HTTP_NOT_FOUND)
。不過,我在瀏覽器(IE)中打開網站沒有問題。HTTPURLConnection.getContent java.io.FileNotFoundException
爲什麼不同,我能做些什麼呢?
這是我的計劃:
String responseMsg = "";
String cgsUrl = "http://localhost:9081/ntes/";
URL url = new URL(cgsUrl);
System.out.println("ouuuuuuu-->"+url.getContent());
InputStream in = url.openConnection().getInputStream();
StringBuffer respDataBuf = new StringBuffer();
respDataBuf.setLength(0);
int b = -1;
while((b = in.read()) != -1) {
respDataBuf.append((char)b);
}
responseMsg = respDataBuf.toString();
你在服務器端使用servlet嗎?它是否接受get和post請求? –
您能告訴我們錯誤堆棧跟蹤嗎? –
它沒有System.out.println(「ouuuuuuu - >」+ url.getContent()); ? –