Skip to content

Commit af2e296

Browse files
committed
Javadoc
1 parent 1838ddb commit af2e296

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
* <pre class="code">
3434
*
3535
* MultipartBodyBuilder builder = new MultipartBodyBuilder();
36-
* MultiValueMap&lt;String, String&gt; form = new LinkedMultiValueMap&lt;&gt;();
37-
* form.add("form field", "form value");
38-
* builder.part("form", form).header("Foo", "Bar");
36+
* builder.part("form field", "form value");
3937
*
4038
* Resource image = new ClassPathResource("image.jpg");
4139
* builder.part("image", image).header("Baz", "Qux");

spring-web/src/main/java/org/springframework/web/client/RestOperations.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String
149149
* the {@code Location} header. This header typically indicates where the new resource is stored.
150150
* <p>URI Template variables are expanded using the given URI variables, if any.
151151
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
152-
* add additional HTTP headers to the request.
152+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
153+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
154+
* simulate a multipart from submission.
153155
* @param url the URL
154156
* @param request the Object to be POSTed (may be {@code null})
155157
* @param uriVariables the variables to expand the template
@@ -164,7 +166,9 @@ <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String
164166
* the {@code Location} header. This header typically indicates where the new resource is stored.
165167
* <p>URI Template variables are expanded using the given map.
166168
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
167-
* add additional HTTP headers to the request.
169+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
170+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
171+
* simulate a multipart from submission.
168172
* @param url the URL
169173
* @param request the Object to be POSTed (may be {@code null})
170174
* @param uriVariables the variables to expand the template
@@ -179,7 +183,9 @@ URI postForLocation(String url, @Nullable Object request, Map<String, ?> uriVari
179183
* Create a new resource by POSTing the given object to the URL, and returns the value of the
180184
* {@code Location} header. This header typically indicates where the new resource is stored.
181185
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
182-
* add additional HTTP headers to the request.
186+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
187+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
188+
* simulate a multipart from submission.
183189
* @param url the URL
184190
* @param request the Object to be POSTed (may be {@code null})
185191
* @return the value for the {@code Location} header
@@ -193,7 +199,9 @@ URI postForLocation(String url, @Nullable Object request, Map<String, ?> uriVari
193199
* and returns the representation found in the response.
194200
* <p>URI Template variables are expanded using the given URI variables, if any.
195201
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
196-
* add additional HTTP headers to the request.
202+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
203+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
204+
* simulate a multipart from submission.
197205
* @param url the URL
198206
* @param request the Object to be POSTed (may be {@code null})
199207
* @param responseType the type of the return value
@@ -210,7 +218,9 @@ <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
210218
* and returns the representation found in the response.
211219
* <p>URI Template variables are expanded using the given map.
212220
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
213-
* add additional HTTP headers to the request.
221+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
222+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
223+
* simulate a multipart from submission.
214224
* @param url the URL
215225
* @param request the Object to be POSTed (may be {@code null})
216226
* @param responseType the type of the return value
@@ -226,7 +236,9 @@ <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
226236
* Create a new resource by POSTing the given object to the URL,
227237
* and returns the representation found in the response.
228238
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
229-
* add additional HTTP headers to the request.
239+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
240+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
241+
* simulate a multipart from submission.
230242
* @param url the URL
231243
* @param request the Object to be POSTed (may be {@code null})
232244
* @param responseType the type of the return value
@@ -241,7 +253,9 @@ <T> T postForObject(String url, @Nullable Object request, Class<T> responseType,
241253
* and returns the response as {@link ResponseEntity}.
242254
* <p>URI Template variables are expanded using the given URI variables, if any.
243255
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
244-
* add additional HTTP headers to the request.
256+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
257+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
258+
* simulate a multipart from submission.
245259
* @param url the URL
246260
* @param request the Object to be POSTed (may be {@code null})
247261
* @param uriVariables the variables to expand the template
@@ -257,7 +271,9 @@ <T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<
257271
* and returns the response as {@link HttpEntity}.
258272
* <p>URI Template variables are expanded using the given map.
259273
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
260-
* add additional HTTP headers to the request.
274+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
275+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
276+
* simulate a multipart from submission.
261277
* @param url the URL
262278
* @param request the Object to be POSTed (may be {@code null})
263279
* @param uriVariables the variables to expand the template
@@ -272,7 +288,9 @@ <T> ResponseEntity<T> postForEntity(String url, @Nullable Object request, Class<
272288
* Create a new resource by POSTing the given object to the URL,
273289
* and returns the response as {@link ResponseEntity}.
274290
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to
275-
* add additional HTTP headers to the request.
291+
* add additional HTTP headers to the request. The body of the entity, or {@code request} itself,
292+
* can be a {@link org.springframework.http.client.MultipartBodyBuilder MultiValueMap} to
293+
* simulate a multipart from submission.
276294
* @param url the URL
277295
* @param request the Object to be POSTed (may be {@code null})
278296
* @return the converted object

spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ public static FormInserter<String> fromFormData(String key, String value) {
220220

221221
/**
222222
* Return a {@code FormInserter} that writes the given {@code MultiValueMap}
223-
* as multipart data. Note that the returned inserter allows for additional entries to be added
223+
* as multipart data. The {@code multipartData} parameter can conveniently be built using the
224+
* {@link org.springframework.http.client.MultipartBodyBuilder MultipartBodyBuilder}.
225+
* Note that the returned inserter allows for additional entries to be added
224226
* via {@link FormInserter#with(String, Object)}.
225227
*
226228
* <p><strong>Note:</strong> you can also use the {@code syncBody(Object)}
@@ -243,8 +245,11 @@ public static <T> FormInserter<T> fromMultipartData(MultiValueMap<String, T> mul
243245
}
244246

245247
/**
246-
* Return a {@code FormInserter} that writes the key-value pair as multipart data. Note that
247-
* the returned inserter allows for additional entries to be added via
248+
* Return a {@code FormInserter} that writes the key-value pair as multipart data. The
249+
* {@code multipartData} parameter can conveniently be built using the
250+
* {@link org.springframework.http.client.MultipartBodyBuilder MultipartBodyBuilder}.
251+
* Note that the returned inserter allows for additional entries to be added
252+
* via {@link FormInserter#with(String, Object)}.
248253
* {@link FormInserter#with(String, Object)}.
249254
* @param key the key to add to the form
250255
* @param value the value to add to the form

0 commit comments

Comments
 (0)