自定义拦截器
2017-11-22 10:25
59 查看
先添加依赖
//okhttp依赖
compile 'com.squareup.okhttp3:okhttp:3.9.0'
//拦截器依赖
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
//banner依赖
compile 'com.youth.banner:banner:1.4.10'
//Gson依赖
compile 'com.google.code.gson:gson:2.8.2'
//evenbus依赖
compile 'org.greenrobot:eventbus:3.1.1'
//图片依赖
compile'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
import java.io.IOException;
import okhttp3.FormBody;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/**
* Created by peng on 2017/11/20.
*/
public class MyInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
}
//okhttp依赖
compile 'com.squareup.okhttp3:okhttp:3.9.0'
//拦截器依赖
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
//banner依赖
compile 'com.youth.banner:banner:1.4.10'
//Gson依赖
compile 'com.google.code.gson:gson:2.8.2'
//evenbus依赖
compile 'org.greenrobot:eventbus:3.1.1'
//图片依赖
compile'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
import java.io.IOException;
import okhttp3.FormBody;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/**
* Created by peng on 2017/11/20.
*/
public class MyInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request(); String url = request.url().url().toString(); url+="&source=android"; Request newRequset = request.newBuilder().url(url).build(); return chain.proceed(newRequset); }
}
相关文章推荐
- SpringMVC DispatcherServlet重写、自定义拦截器拦截器(一)
- struts2自定义拦截器
- SpringMVC经典系列-14自定义SpringMVC的拦截器---【LinusZhu】
- Struts2自定义拦截器—Session超时的处理
- Struts2自定义拦截器验证登录
- 使用struts2自定义拦截器,要引入defaultStack
- play框架自定义插件plugin拦截器
- 使用token拦截器(自定义拦截器的使用(不重要))
- struts自定义拦截器的三种方式
- 自定义注解+拦截器实现权限控制
- Struts2中自定义拦截器
- Struts2自定义拦截器实例—只允许从登录页面进入系统
- 自定义我的拦截器
- 自定义拦截器1
- Struts2自定义拦截器
- SpringMVC——自定义拦截器、异常处理以及父子容器配置
- Struts2自定义拦截器
- struts2学习笔记(9)——自定义拦截器
- struts2自定义拦截器与cookie整合实现用户免重复登入
- Struts2 自定义拦截器栈后无法得到表单参数之解决办法