我正在尝试使用字符串列表发出GET请求。
像这样表示列表的改造;
/endpoint?GTIN=111>IN=222
但是服务器(Springboot)只给出最后一个的结果。
它是这样工作的
/endpoint?GTIN=111,222
有没有一种方法可以在改造中实现后者?
发布于 2020-06-13 04:26:48
您可以尝试使用Retrofit的@Url
注释来生成所需的URL。
在您的服务接口文件中对API方法进行更改,
public interface YourServiceInterface {
@GET() // DO NOT pass any arguments here
Call<YourResponseObject> foo(@Url String url); // use @Url annotation here
}
在你的活动或片段中。
String url = BASE_URL + "/endpoint?GTIN=111,222"; // https://example.com/endpoint?GTIN=111,222
YourServiceInterface api = ....;
Call<YourResponseObject> call = api.foo(url);
call.enqueue(/* implementation */);
https://stackoverflow.com/questions/62345904
复制相似问题