javadoc
This commit is contained in:
parent
689e7b7af2
commit
5105793228
|
|
@ -23,7 +23,9 @@ import org.springframework.util.MultiValueMap;
|
|||
*
|
||||
* <p>Typically used in combination with the {@link org.springframework.web.client.RestTemplate RestTemplate}, like so:
|
||||
* <pre class="code">
|
||||
* HttpEntity<String> entity = new HttpEntity<String>(helloWorld, MediaType.TEXT_PLAIN);
|
||||
* 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);
|
||||
* </pre>
|
||||
* or
|
||||
|
|
@ -33,12 +35,12 @@ import org.springframework.util.MultiValueMap;
|
|||
* MediaType contentType = entity.getHeaders().getContentType();
|
||||
* </pre>
|
||||
* Can also be used in Spring MVC, as a return value from a @Controller method:
|
||||
* <pre>
|
||||
* <pre class="code">
|
||||
* @RequestMapping("/handle")
|
||||
* public HttpEntity<String> handle() {
|
||||
* public HttpEntity<String> handle() {
|
||||
* HttpHeaders responseHeaders = new HttpHeaders();
|
||||
* responseHeaders.set("MyResponseHeader", "MyValue");
|
||||
* return new HttpEntity<String>("Hello World", responseHeaders);
|
||||
* return new HttpEntity<String>("Hello World", responseHeaders);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -21,6 +21,24 @@ import org.springframework.util.MultiValueMap;
|
|||
/**
|
||||
* Extension of {@link HttpEntity} that adds a {@link HttpStatus} status code.
|
||||
*
|
||||
* <p>Returned by {@link org.springframework.web.client.RestTemplate#getForEntity}:
|
||||
* <pre class="code">
|
||||
* ResponseEntity<String> entity = template.getForEntity("http://example.com", String.class);
|
||||
* String body = entity.getBody();
|
||||
* MediaType contentType = entity.getHeaders().getContentType();
|
||||
* HttpStatus statusCode = entity.getStatusCode();
|
||||
* </pre>
|
||||
* Can also be used in Spring MVC, as a return value from a @Controller method:
|
||||
* <p>Can be used in Spring MVC, as a return value from a @Controller method:
|
||||
* <pre class="code">
|
||||
* @RequestMapping("/handle")
|
||||
* public ResponseEntity<String> handle() {
|
||||
* HttpHeaders responseHeaders = new HttpHeaders();
|
||||
* responseHeaders.set("MyResponseHeader", "MyValue");
|
||||
* return new ResponseEntity<String>("Hello World", responseHeaders, HttpStatus.CREATED);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 3.0.2
|
||||
* @see #getStatusCode()
|
||||
|
|
|
|||
Loading…
Reference in New Issue