Retrofit2(二):get请求

2017-10-10  本文已影响0人  hiandg

带参数

@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) {

}

});

上一篇下一篇

猜你喜欢

热点阅读