| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.http.HttpEntity<T>
org.springframework.http.ResponseEntity<T>
public class ResponseEntity<T>
Extension of HttpEntity that adds a HttpStatus status code.
 
Returned by RestTemplate.getForEntity(java.lang.String, java.lang.Class:
 
 ResponseEntity<String> entity = template.getForEntity("http://example.com", String.class);
 String body = entity.getBody();
 MediaType contentType = entity.getHeaders().getContentType();
 HttpStatus statusCode = entity.getStatusCode();
 
 Can also be used in Spring MVC, as a return value from a @Controller method:
 @RequestMapping("/handle")
 public ResponseEntity<String> handle() {
   HttpHeaders responseHeaders = new HttpHeaders();
   responseHeaders.set("MyResponseHeader", "MyValue");
   return new ResponseEntity<String>("Hello World", responseHeaders, HttpStatus.CREATED);
 }
 
getStatusCode()| Field Summary | 
|---|
| Fields inherited from class org.springframework.http.HttpEntity | 
|---|
| EMPTY | 
| Constructor Summary | |
|---|---|
| ResponseEntity(HttpStatus statusCode)Create a new ResponseEntitywith the given status code, and no body nor headers. | |
| ResponseEntity(MultiValueMap<String,String> headers,
               HttpStatus statusCode)Create a new HttpEntitywith the given headers and status code, and no body. | |
| ResponseEntity(T body,
               HttpStatus statusCode)Create a new ResponseEntitywith the given body and status code, and no headers. | |
| ResponseEntity(T body,
               MultiValueMap<String,String> headers,
               HttpStatus statusCode)Create a new HttpEntitywith the given body, headers, and status code. | |
| Method Summary | |
|---|---|
|  HttpStatus | getStatusCode()Return the HTTP status code of the response. | 
| Methods inherited from class org.springframework.http.HttpEntity | 
|---|
| getBody, getHeaders, hasBody | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public ResponseEntity(HttpStatus statusCode)
ResponseEntity with the given status code, and no body nor headers.
statusCode - the status code
public ResponseEntity(T body,
                      HttpStatus statusCode)
ResponseEntity with the given body and status code, and no headers.
body - the entity bodystatusCode - the status code
public ResponseEntity(MultiValueMap<String,String> headers,
                      HttpStatus statusCode)
HttpEntity with the given headers and status code, and no body.
headers - the entity headersstatusCode - the status code
public ResponseEntity(T body,
                      MultiValueMap<String,String> headers,
                      HttpStatus statusCode)
HttpEntity with the given body, headers, and status code.
body - the entity bodyheaders - the entity headersstatusCode - the status code| Method Detail | 
|---|
public HttpStatus getStatusCode()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||