Andorid Http请求返回405

public static String sendPostMessage(String path,String encoding)
    {
        String result="";
        
        HttpClient httpClient = new DefaultHttpClient();
        
        try {
            HttpGet post = new HttpGet(path);
            HttpResponse httpResponse = httpClient.execute(post);
            if( httpResponse.getStatusLine().getStatusCode()==200)
            {
                result=EntityUtils.toString(httpResponse.getEntity(), encoding);
                
            }
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }finally
        {

            httpClient.getConnectionManager().shutdown();
        }
        
        return result;
    
    }
   

以上方法发起的请求,服务请会返回405

把HttpPost改成HttpGet,就OK了


你可能感兴趣的:(Andorid Http请求返回405)