OkHttp之get请求

使用HttpUrl构造get请求参数

HttpUrl httpUrl = HttpUrl.parse("http://www.baidu.com").newBuilder()
        .addPathSegment("login")
        .addQueryParameter("username","admin")
        .addQueryParameter("password","123456")
        .build();
Request r = new Request.Builder()
        .url(httpUrl)
        .build();
Log.e(TAG, "请求url:"+ httpUrl.url() );

版权声明:本文为Bosom_Friend原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。