问题描述
我的代码是这样的:publicsynchronizedintexecuteMethod(Stringfilename,intstatus)throwsIOException{if(status==0){PostMethodp=newPostMethod(url);p.setFollowRedirects(false);try{a.executeMethod(p);FilestoreFile=newFile(filename);FileOutputStreamoutput=newFileOutputStream(storeFile);output.write(p.getResponseBody());output.close();output=null;p.releaseConnection();storeFile=null;if(p!=null){p.recycle();p=null;}}catch(Exceptione){try{throwe;}catch(Exceptione1){e1.printStackTrace();}}}else{if(status==1){GetMethodg=newGetMethod(url);try{a.executeMethod(g);FilestoreFile=newFile(filename);FileOutputStreamoutput=newFileOutputStream(storeFile);output.write(g.getResponseBody());output.close();output=null;g.releaseConnection();storeFile=null;if(g!=null){g.recycle();g=null;}}catch(Exceptione){try{throwe;}catch(Exceptione1){e1.printStackTrace();}}}returnstatus;}每次执行到a.executeMethod(g);时就会出现RedirectrequestedbutfollowRedirectsisdisabled的错误,请问该怎么解决,请高手指教
解决方案
解决方案二:
PostMethod这个地方出问题了,应该使用GetMethod
解决方案三:
大神啊,太感谢你了