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


/**
 * 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM