Ras*_*iri 1 java android kotlin retrofit retrofit2
我使用改造和我的界面如下
\n\n @GET("{link}")\n fun search(@Path(value = "link", encoded = true) link: String?): Call<Any>\nRun Code Online (Sandbox Code Playgroud)\n\n我是否需要对除字符“?\”之外的所有链接使用编码。
\n\n例子:
\n\n链接-> /api/search?&query=\xd8\xaa\xd8\xb3\xd8\xaa
\n\n通过改造编码链接 -> api/search%3F&query=%D8%AA%D8%B3%D8%AA
\n\n我需要这个链接-> api/search?&query=%D8%AA%D8%B3%D8%AA
\n\n我不需要将字符\'?\'转换为%3F。\ndo 是什么呢?
\n小智 5
应该使用 @Url 而不是 @Path
@GET
Call<ResponseClass> list(@Url String url);
Run Code Online (Sandbox Code Playgroud)
它可以很好地处理完整的 URL 以及随后与基本 URL 一起使用的路径。
Retrofit retrofit = Retrofit.Builder()
.baseUrl("https://website.com/");
.build();
MyService service = retrofit.create(MyService.class);
service.exampleCall("https://another-website.com/example");
service.anotherExampleCall("/only/path/part");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1719 次 |
| 最近记录: |