Retrofit2.0 返回 404 not found

编程入门 行业动态 更新时间:2024-10-25 16:29:35
本文介绍了Retrofit2.0 返回 404 not found的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Retrofit retrofit = new Retrofit.Builder() .baseUrl("ipAdress/SaveImg/DouBanGirl") .addConverterFactory(GsonConverterFactory.create()) .build(); imgApi imgService = retrofit.create(imgApi.class); Call<Img> imgCall = imgService.getImg("20151119"); imgCall.enqueue(new Callback<Img>() { @Override public void onResponse(retrofit.Response<Img> response, Retrofit retrofit) { Log.d(TAG, response.code() + " "); } @Override public void onFailure(Throwable t) { Log.d(TAG, t.getMessage()); } }); } public interface imgApi { @GET("/DouBanGirl") Call<Img> getImg(@Query("date") String date); }

当我尝试此操作时,它显示未找到 404.网址是正确的,我检查过.我不知道发生了什么.

when i tried this, it is showing 404 not found. the url is correct, i checked that. I dont know what going on.

推荐答案

由于 Retrofit 2.0 如何使用 Http Resolve 来解析端点的 uri 方案,如果您像这样指定 baseurl hello 和端点 URL 为 /world/foo 它会中断.

Due to how Retrofit 2.0 uses Http Resolve for resolving the uri scheme of your endpoints, if you specify the baseurl like this hello and the endpoint URL as /world/foo it will break.

您需要使用基本 URL hello/ 和端点 URL world/foo.

You need to use base URL hello/ and endpoint URL world/foo.

/ 有所作为.

更多推荐

Retrofit2.0 返回 404 not found

本文发布于:2023-11-16 15:03:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605357.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!