parent
b3eb1a2ad7
commit
ec3f857bda
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -23,12 +23,12 @@ import org.springframework.util.ObjectUtils;
|
||||||
/**
|
/**
|
||||||
* Represents an HTTP request or response entity, consisting of headers and body.
|
* Represents an HTTP request or response entity, consisting of headers and body.
|
||||||
*
|
*
|
||||||
* <p>Typically used in combination with the {@link org.springframework.web.client.RestTemplate},
|
* <p>Often used in combination with the {@link org.springframework.web.client.RestTemplate},
|
||||||
* like so:
|
* like so:
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* HttpHeaders headers = new HttpHeaders();
|
* HttpHeaders headers = new HttpHeaders();
|
||||||
* headers.setContentType(MediaType.TEXT_PLAIN);
|
* headers.setContentType(MediaType.TEXT_PLAIN);
|
||||||
* HttpEntity<String> entity = new HttpEntity<String>("helloWorld", headers);
|
* HttpEntity<String> entity = new HttpEntity<>("Hello World", headers);
|
||||||
* URI location = template.postForLocation("https://example.com", entity);
|
* URI location = template.postForLocation("https://example.com", entity);
|
||||||
* </pre>
|
* </pre>
|
||||||
* or
|
* or
|
||||||
|
|
@ -39,11 +39,11 @@ import org.springframework.util.ObjectUtils;
|
||||||
* </pre>
|
* </pre>
|
||||||
* Can also be used in Spring MVC, as a return value from a @Controller method:
|
* Can also be used in Spring MVC, as a return value from a @Controller method:
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* @RequestMapping("/handle")
|
* @GetMapping("/handle")
|
||||||
* public HttpEntity<String> handle() {
|
* public HttpEntity<String> handle() {
|
||||||
* HttpHeaders responseHeaders = new HttpHeaders();
|
* HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
* responseHeaders.set("MyResponseHeader", "MyValue");
|
* responseHeaders.set("MyResponseHeader", "MyValue");
|
||||||
* return new HttpEntity<String>("Hello World", responseHeaders);
|
* return new HttpEntity<>("Hello World", responseHeaders);
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue