HttpEntity
2015-07-12 00:00
555 查看
摘要: 在阅读http相关工程的时候,有个httpentity 概念?它到底是干啥的呢?
Represents an HTTP request or response entity, consisting of headers and body.
HttpEntity 代表一个request请求或者响应,包含header和body,就包含头和体。
Typically used in combination with the
另外对于spring RestTemplate 的说明。
Spring's central class for synchronous client-side HTTP access. It simplifies communication with HTTP servers, and enforces RESTful principles. It handles HTTP connections, leaving application code to provide URLs (with possible template variables) and extract results.
The main entry points of this template are the methods named after the six main HTTP methods:
or
Can also be used in Spring MVC, as a return value from a @Controller method:
public class HttpEntity<T>extends Object
Represents an HTTP request or response entity, consisting of headers and body.
HttpEntity 代表一个request请求或者响应,包含header和body,就包含头和体。
Typically used in combination with the
RestTemplate, like so:
HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); HttpEntity<String> entity = new HttpEntity<String>(helloWorld, headers); URI location = template.postForLocation("http://example.com", entity);
public class RestTemplate extends InterceptingHttpAccessorimplements RestOperations
另外对于spring RestTemplate 的说明。
Spring's central class for synchronous client-side HTTP access. It simplifies communication with HTTP servers, and enforces RESTful principles. It handles HTTP connections, leaving application code to provide URLs (with possible template variables) and extract results.
The main entry points of this template are the methods named after the six main HTTP methods:
or
HttpEntity<String> entity = template.getForEntity("http://example.com", String.class); String body = entity.getBody(); MediaType contentType = entity.getHeaders().getContentType();
Can also be used in Spring MVC, as a return value from a @Controller method:
@RequestMapping("/handle") public HttpEntity<String> handle() { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.set("MyResponseHeader", "MyValue"); return new HttpEntity<String>("Hello World", responseHeaders); }
相关文章推荐
- Android使用MultipartEntityBuilder实现类似form表单提交方式的文件上传
- HttpEntity转为List<JavaBean>
- HttpEntity错误的问题
- 完美解决Multipart EntityBuilder.addtextbody && http entity中文乱码
- HttpEntity
- 接收httpPost请求HttpEntity方式
- HttpEntity的结果解析为JSON
- python网络基础编程笔记(一)
- https原理及tomcat配置https方法
- 浅悉软考网络工程师考试出题风格变化
- tinyhttpd学习笔记(一)编译错误及运行结果
- 网络错误代码
- 聊聊HTTPS和SSL/TLS协议
- 基于复杂城市道路场景的消失点检测 Vanishing point detction(IET Computer Vision)个人主页:http://www.newneu.neu.edu.cn/?p=1
- HTTP::Request
- NS3网络仿真(5): 数据包分析
- 考试前的零散学习【1】网络地址a.b.c.d/x;数据报分片
- NetworkRequest网络请求数据类
- 神经网络的基础学习
- httpClient通过post上传数据