首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android4.0中HttpURLConnection抛错误java.io.FileNotFoundException

2012-06-29 
android4.0中HttpURLConnection抛异常java.io.FileNotFoundExceptionURL url new URL(urlstr)HttpURLCo

android4.0中HttpURLConnection抛异常java.io.FileNotFoundException

URL url = new URL(urlstr);
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setRequestMethod("GET");
httpCon.setDoOutput(true);
httpCon.connect();

?

原因:
4.0中设置httpCon.setDoOutput(true),将导致请求以post方式提交,即使设置了httpCon.setRequestMethod("GET");
将代码中的httpCon.setDoOutput(true);删除即可

热点排行