我正在使用以下代码行调用POST网络服务。我不清楚connection.setDoOutput(true);和connection.setDoInput(true);能否详细说明这段代码的用途?我能否将相同的代码与GET一起使用?URLurl=newURL("http://xxxxxx.com");HttpURLConnectionconnection=(HttpURLConnection)url.openConnection();connection.setRequestMethod("POST");connection.setDoOutput(true);connection.se
HttpURLConnection.setDoInput和HttpURLConnection.setDoOutput的作用或目的是什么? 最佳答案 来自URLConnection的文档:SettheDoInputflagtotrueifyouintendtousetheURLconnectionforinput,falseifnot.Thedefaultistrue.SettheDoOutputflagtotrueifyouintendtousetheURLconnectionforoutput,falseifnot.Thedefa
HttpURLConnection.setDoInput和HttpURLConnection.setDoOutput的作用或目的是什么? 最佳答案 来自URLConnection的文档:SettheDoInputflagtotrueifyouintendtousetheURLconnectionforinput,falseifnot.Thedefaultistrue.SettheDoOutputflagtotrueifyouintendtousetheURLconnectionforoutput,falseifnot.Thedefa
自从更新到IceCreamSandwich后,我的POST请求不再有效。在ICS之前,这工作正常:try{finalURLurl=newURL("http://example.com/api/user");finalHttpURLConnectionconnection=(HttpURLConnection)url.openConnection();connection.setRequestMethod("POST");connection.setDoOutput(false);connection.setDoInput(true);connection.setRequestPrope
URLConnection中有setDoOutput()。根据documentation我应该SettheDoOutputflagtotrueifyouintendtousetheURLconnectionforoutput,falseifnot.现在我面对的是exactlythisproblem-一旦setDoOutput(true)被调用,Java运行时将请求转换为POST并且服务器只响应GET请求。我想了解如果我从代码中删除该setDoOutput(true)会发生什么。这究竟会影响什么?假设我将它设置为false-我现在可以做什么,现在不能做什么?我可以执行GET请求吗?这种方