Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://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);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,显示404未找到.网址是正确的,我查了一下.我不知道发生了什么.
由于Retrofit 2.0如何使用Http Resolve来解析端点的uri方案,如果你指定像这样的baseurl http://hello.com和端点URL,因为/world/foo它会破坏.
您需要使用基本URL http://hello.com/和端点URL world/foo.
将/产生变化.
| 归档时间: |
|
| 查看次数: |
3181 次 |
| 最近记录: |