且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的HTTP请求奇怪404未找​​到问题

更新时间:2023-10-21 15:50:28

问题解决了:)

      try {

            url = new URL(serverURL);

            Log.i(LOG_TAG, url+"");
            HttpGet method= new HttpGet(new URI(serverURL));
            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet();
            request.setURI(new URI(serverURL));
            HttpResponse response = client.execute(method);
            responseCode = response.getStatusLine().getStatusCode();

            Log.i(LOG_TAG,"Response code response "+response);
            Log.i(LOG_TAG,"Response responseCode "+responseCode);
        } catch (Exception e) {
            e.printStackTrace();
        }