android - 改造斜杠作为查询
问题描述
我正在尝试从此 api 下载数据:
https://chicken-coop.fr/rest/games/fifa%2019?platform=switch
这是我的接口类:
public interface GamesInterface {
@GET("/rest/games")
Call<Example> getGamesbyName(@Query("/") String gameName, @Query("platform") String gamePlatform);
}
目前我可以使用微调器更改布局中的平台名称,但我不知道如何更改游戏名称。如何使用斜杠作为@Query("platform")
?
解决方案
您可以执行以下操作:
public interface GamesInterface {
@GET("/rest/games/{gameName}")
Call<Example> getGamesbyName(@Path("gameName") String gameName, @Query("platform") String gamePlatform);
}
注意@Path
注释,它将 a 映射String
到 url。您可以通过以下网址阅读更多关于改造的信息:https ://square.github.io/retrofit/
推荐阅读
- python - 在模块之间传递对象实例的正确方法
- c++ - C++:我的链表尾部没有改变?我似乎无法让节点正确指向彼此?
- javascript - 如何检查 3 个变量中的每一个是否都是空字符串?
- python - 重命名单个值
- c - 我在 C 中的 decToBase 方法出错并返回
- python - 来自 Databricks 的 Python 代码连接到 SQL 服务器
- c - C程序写入目录的内容
- django - 我可以从单个 Django 函数中分别返回模板和变量吗?
- azure - 使用 Redisson 和 Azure Redis 缓存遇到 RedisTimeoutException 和其他异常
- docker - 如何将 CA 根证书添加到 Jenkins Docker 容器上的 LDAP 密钥库?