以下代码段尝试连接到 url。该 url 还发送一个名为FileNames
. 但是当我运行这个片段时,我总是得到HTTP Version Not Supported
回复。可能是什么原因?
try {
URL url = new URL(AddressInformation.clientAddressToSendFileNames + URLEncoder.encode(list.toString(), "UTF-8")); // STATEMENT-1
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if(connection.getResponseCode() == 200) {
// File names sent to the client that requested it
System.out.println("File names sent");
} else {
// Error : While trying to send the file names
System.out.println("Unable to send file names");
System.out.println("RESPONSE CODE ------->>>>" + connection.getResponseMessage());
}
} catch(Exception exc) {
exc.printStackTrace();
}
在 STATEMENT-1 中,AddressInformation.clientAddressToSendFileNames
对应于
http://localhost:8084/D Nappster/ReceiveFileNames?FileNames=
.
我正在运行 Tomcat 7。