Spring的构造请求类 SimpleClientHttpRequestFactory
2016-05-05 23:33
471 查看
今天看到了Spring提供的SimpleClientHttpRequestFactory类,能够构造http request请求,下面是spring的doc地址
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/SimpleClientHttpRequestFactory.html
简单例子:
String url = "http://localhost:8080/clientRequestFacory/hello";
//构造请求对象
ClientHttpRequest request =new SimpleClientHttpRequestFactory().createRequest(new URI(url), HttpMethod.POST);
//设置请求头
request.getHeaders().set("Accept", "application/json");
//发送请求
ClientHttpResponse response = request.execute();
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/SimpleClientHttpRequestFactory.html
简单例子:
String url = "http://localhost:8080/clientRequestFacory/hello";
//构造请求对象
ClientHttpRequest request =new SimpleClientHttpRequestFactory().createRequest(new URI(url), HttpMethod.POST);
//设置请求头
request.getHeaders().set("Accept", "application/json");
//发送请求
ClientHttpResponse response = request.execute();
相关文章推荐
- [javaSE] 网络编程(概述)
- BP神经网络的实例一则
- java socket 网络编程 超详细讲解
- 安卓GridView异步加载网络图片
- Java 网络编程
- HTTP返回状态码总结
- MTK Http Socket GPRS以及解析器和下载器概述
- 机器学习之神经网络bp算法推导
- HTTPS
- 网络仿真工具TOTEM之——Worst Case Analysis
- [每日一问]虚拟化网络设计中为什么建议采用链路聚合
- 网络仿真工具TOTEM之——场景的执行
- UDP套接字的使用介绍
- JAVA Web(http协议和servlet)
- java网络编程小结
- "https://open.gl/"教程之Textures源码(freeglut版)
- 谷歌chrome浏览器和火狐firefox浏览器自带http抓包工具和请求模拟插件
- "https://open.gl/"教程之Drawing Polygons源码(freeglut版)
- [每日一问]虚拟化网络设计中为什么建议采用链路聚合
- Httpclient核心架构设计