Android 在改型中如何在查询字符串中使用@Path?
我有一个类似Android 在改型中如何在查询字符串中使用@Path?,android,retrofit,retrofit2,Android,Retrofit,Retrofit2,我有一个类似http://www.example.com/index.php?apiex/teacher/2我想要http://www.example.com/index.php?apiex/teacher/{teacher_id},不是这样的http://www.example.com/index.php?apiex/teacher?teacher_id=2 使用likegetTeacher(@Path(“teacher\u id”)字符串teacherId)会给我一个异常: java.lan
http://www.example.com/index.php?apiex/teacher/2
我想要http://www.example.com/index.php?apiex/teacher/{teacher_id}
,不是这样的http://www.example.com/index.php?apiex/teacher?teacher_id=2
使用likegetTeacher(@Path(“teacher\u id”)字符串teacherId)
会给我一个异常:
java.lang.IllegalArgumentException:URL查询字符串“apiex/teacher/{teacher\u id}”不能有替换块。对于动态查询参数,请使用@query
我的改装界面如下所示:
@GET(“apiex/teacher/{teacher\u id}”)
ObservableGetCacher(@Path(“teacher_id”)字符串teacherId);
基本URL是
http://www.example.com/index.php?
。而且我不能从中删除?
。我看到了,但我想要如上所述。将baseurl设置为这样,而不是
? 就像它看到的那样,接下来呢?作为查询,这就是为什么它说,块后的?是查询您可以显示您的改装界面吗?在
getTeacher()
之前的注释是什么?@azizbekian我已经添加了这应该是正确的注释,因为“?”之后的任何内容都被视为查询参数。@azizbekian我知道,但我使用codeigniter完成了这项操作,所以如果我删除了该注释,我希望在之后使用动态url?它不会工作或给出响应,因为您可以使用和替换参数来处理它。