HttpURLConnection用GET方式请求一个http接口,接口返回的是一个json文件,报406错误代码:URL url = new URL(urlstr);connection = (HttpURLConnection) url.openConnection();connection.setConnectTimeout(50000);connection.setRequestMethod("GET");int responseCode = connection.getResponseCode();//这里返回406if (responseCode == 200) { is = connection.getInputStream(); ......}如果设置connection.setRequestProperty("accept", "*/*");这句则会返回405,请问这是什么原因?有谁遇到过?
添加回答
举报
0/150
提交
取消