Retrofit之Query注解
来源:互联网 发布:淘宝网div css布局实例 编辑:程序博客网 时间:2024/06/12 23:35
@Query
其实源码的注释已经说的很清楚了,且当做个翻译工吧~
1.Get
一些共同的代码。。先码好
Retrofit retrofit=new Retrofit.Builder() .baseUrl("http://xxxx") .addConverterFactory(GsonConverterFactory.create()) .build();Get get=retrofit.create(Get.class);
1)假设你的get请求地址是类似以下格式的:http://xxxx/vvvv/list?page=1
那你可以这样写
public interface Get{ @GET("/vvvv/list") Call<ResponseBody> list(@Query("page") String page);}Call<ResponseBody> call=get.list("1");
2)假设你的get请求地址是类似以下格式的:http://xxxx/vvvv/list?category=1&category=2
public interface Get{ @GET("/vvvv/list") Call<ResponseBody> list(@Query("category") String... categories);}Call<ResponseBody> call=get.list("bar", "baz");
3)假设你想传一个这样的参数:”foo+bar”,又不想你的参数中的符号(+号)被URL编码(http://xxxx/vvvv/list?category=foo+bar),可以这样写
public interface Get{ @GET("/vvvv/list") Call<ResponseBody> list(@Query(value="categories", encoded=true) String categories);}Call<ResponseBody> call=get.list("foo+bar");
另外可能没法用在post上面,暂时还没发现。。。。
1 0
- Retrofit之Query注解
- 【Android】Retrofit网络请求参数注解,@Path、@Query、@QueryMap...
- 【Android】Retrofit网络请求参数注解,@Path、@Query、@QueryMap...
- Retrofit网络请求参数注解,@Path、@Query、@QueryMap...
- Retrofit网络请求参数注解,@Path、@Query、@QueryMap...
- Retrofit网络请求参数注解,@Path、@Query、@QueryMap的使用
- Retrofit注解
- Spring data jpa 之 Query注解
- 注解@Query
- Retrofit 注解字段说明
- Retrofit 注解 详解
- retrofit 注解含义
- Retrofit的注解使用
- Retrofit新手常用注解
- retrofit 注解学习
- Retrofit 注解使用
- Retrofit 2.0 个注解详解
- 注解+代理 模仿 Retrofit 传参
- Java 多线程下载技术实现
- 点击图片放大查看
- jquery eval解析JSON中的注意点介绍
- maven上找不到的包到maven库里去搜
- Objective-C特有类型——id
- Retrofit之Query注解
- OSG多线程,多显示场景图形设计
- iOS 当页面中没有数据的时候出现的一个指向创建按钮的 UIView
- Zigbee协议按键触发流程
- start with connect by prior子句实现递归查询
- 在list集合中的添加、修改、删除和遍历元素
- Windows Cython 安装
- Linux useradd 命令
- linux中shell变量$#,$@,$0,$1,$2的含义解释