如何从Retrofit获取响应URL? [英] How to get the response URL from Retrofit?

查看:144
本文介绍了如何从Retrofit获取响应URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将REST项目的Retrofit用于我的android项目.总体上来说,它运行良好,直到我试图从返回URL读取几个参数为止.例如,在网络浏览器上:

I'm using Retrofit for REST web services my android project. It works fine overall untill the point I'm trying to read several parameters from the return URL. For exapmle on the web browser:

  1. 键入" http://foobar.com/"
  2. 点击进入
  3. 它变为" http://foobar2.com/abc=123 "

现在的问题是如何从翻新响应中获取"abc = 123"值.谢谢堆!

Now the question is how do I get that "abc=123" value from retrofit response. Thanks heaps!

推荐答案

我已经解决了问题.这是我的解决方案:

I have solve the problem.Here is my solution:

定义请求

@GET 
Call<String> getSend(@Url String url);

并发送

Api.get(WXApi.class).getSend(ip).enqueue(new Callback<String>() {

    @Override
    public void onResponse(Call<String> call, Response<String> response) {

        Log.d(TAG,"response.raw().request().url();"+response.raw().request().url());}

    @Override
    public void onFailure(Call<String> call, Throwable t) {

    }
});

这篇关于如何从Retrofit获取响应URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆