码迷,mamicode.com
首页 > 编程语言 > 详细

使用Retrofit时出现 java.lang.IllegalArgumentException: URL query string "t={type}&p={page}&size={count}" must not have replace block. For dynamic query parameters use @Query.异常原因

时间:2016-05-02 14:23:04      阅读:2871      评论:0      收藏:0      [点我收藏+]

标签:

/**
 * Created by leo on 16/4/30.
 */
public interface GanchaiService {
    @GET("digest?t={type}&p={page}&size={count}")
    Call<List<GanChaiEntry>> ListGanchaiEntry(@Path("type") int type
            , @Path("count") int count, @Path("page") int page);
}

这里报错

形如?t=1&p=2&size=3的url链接不能用@PATH注解

Query params have their own annotation which automatically appends to the URL.

使用@Query注解

    @GET("digest")
    Call<List<GanChaiEntry>> ListGanchaiEntry(@Query("t")int type
            , @Query("size") int count, @Query("p") int page);

参考:

http://stackoverflow.com/questions/24610243/retrofit-error-url-query-string-must-not-have-replace-block

使用Retrofit时出现 java.lang.IllegalArgumentException: URL query string "t={type}&p={page}&size={count}" must not have replace block. For dynamic query parameters use @Query.异常原因

标签:

原文地址:http://www.cnblogs.com/krislight1105/p/5452202.html

(1)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!