美文网首页
Retrofit2(二):get请求

Retrofit2(二):get请求

作者: hiandg | 来源:发表于2017-10-10 21:15 被阅读0次

带参数

@GET("user/info")

Call getUserInfo(@Query("id") int user_id);

@GET("user/{id}")

Call getUserInfoWithPath(@Path("id") int user_id);

api= retrofit.create(Api.class);

Call userInfo =api.getUserInfo(3);

带多个参数

@GET("user/info")

Call getUserInfoWithMap(@QueryMapMap map);

HashMap map =new HashMap<>();

map.put("id","1");

map.put("id","2");

map.put("id","3");

api.getUserInfoWithMap(map).enqueue(new Callback() {

@Override

public voidonResponse(Call call, Response response) {

}

@Override

public voidonFailure(Call call, Throwable t) {

}

});

相关文章

网友评论

      本文标题:Retrofit2(二):get请求

      本文链接:https://www.haomeiwen.com/subject/ilubyxtx.html