From 442ddb08457bf22afce9622ba9cd82c7415b6832 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 19 Mar 2018 20:38:14 +0100 Subject: [PATCH] Correct documentation of default HttpMessageConverters in RestTemplate Issue: SPR-7885 --- .../converter/FormHttpMessageConverter.java | 11 ++-- src/docs/asciidoc/integration.adoc | 57 ++++++++----------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 3972641a988..a2c8964ff43 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -64,8 +64,10 @@ import org.springframework.util.StringUtils; * *

For example, the following snippet shows how to submit an HTML form: *

- * RestTemplate template = new RestTemplate();  // FormHttpMessageConverter is configured by default
- * MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
+ * RestTemplate template = new RestTemplate();
+ * // AllEncompassingFormHttpMessageConverter is configured by default
+ *
+ * MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
  * form.add("field 1", "value 1");
  * form.add("field 2", "value 2");
  * form.add("field 2", "value 3");
@@ -74,7 +76,7 @@ import org.springframework.util.StringUtils;
  *
  * 

The following snippet shows how to do a file upload: *

- * MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
+ * MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
  * parts.add("field 1", "value 1");
  * parts.add("file", new ClassPathResource("myFile.jpg"));
  * template.postForLocation("http://example.com/myFileUpload", parts);
@@ -87,7 +89,8 @@ import org.springframework.util.StringUtils;
  * @author Rossen Stoyanchev
  * @author Juergen Hoeller
  * @since 3.0
- * @see MultiValueMap
+ * @see org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
+ * @see org.springframework.util.MultiValueMap
  */
 public class FormHttpMessageConverter implements HttpMessageConverter> {
 
diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc
index 6aa0692995c..4399379b762 100644
--- a/src/docs/asciidoc/integration.adoc
+++ b/src/docs/asciidoc/integration.adoc
@@ -1014,23 +1014,23 @@ exception processing the HTTP request, an exception of the type `RestClientExcep
 will be thrown; this behavior can be changed by plugging in another
 `ResponseErrorHandler` implementation into the `RestTemplate`.
 
-The `exchange` and `execute` methods are generalized versions of the more
-specific methods listed above them and can support additional combinations and methods,
-like HTTP PATCH. However, note that the underlying HTTP library must also support the
-desired combination. The JDK `HttpURLConnection` does not support the `PATCH` method, but
-Apache HttpComponents HttpClient version 4.2 or later does. They also enable
-`RestTemplate` to read an HTTP response to a generic type (e.g. `List`), using a
-`ParameterizedTypeReference`, a new class that enables capturing and passing generic
-type info.
+The `exchange` and `execute` methods are generalized versions of the more specific
+methods listed above them and can support additional combinations and methods,
+e.g. HTTP PATCH. However, note that the underlying HTTP library must also support the
+desired combination. The JDK `HttpURLConnection` does not support the `PATCH` method
+but Apache HttpComponents HttpClient version 4.2 or later does. They also enable
+`RestTemplate` to read an HTTP response to a generic type (e.g. `List`),
+using a `ParameterizedTypeReference`, a new class that enables capturing and passing
+generic type info.
 
 Objects passed to and returned from these methods are converted to and from HTTP
-messages by `HttpMessageConverter` instances. Converters for the main mime types are
-registered by default, but you can also write your own converter and register it via the
-`messageConverters()` bean property. The default converter instances registered with the
-template are `ByteArrayHttpMessageConverter`, `StringHttpMessageConverter`,
-`FormHttpMessageConverter` and `SourceHttpMessageConverter`. You can override these
-defaults using the `messageConverters()` bean property as would be required if using the
-`MarshallingHttpMessageConverter` or `MappingJackson2HttpMessageConverter`.
+messages by `HttpMessageConverter` implementations. Converters for the main MIME types
+are registered by default, but you can also override the defaults and register custom
+converters via the `messageConverters()` bean property. The default converters are
+`ByteArrayHttpMessageConverter`, `StringHttpMessageConverter`,
+`ResourceHttpMessageConverter`, `SourceHttpMessageConverter` as well as
+`AllEncompassingFormHttpMessageConverter` and a few provider-specific converters:
+e.g. `MappingJackson2HttpMessageConverter` when Jackson is present on the classpath.
 
 Each method takes URI template arguments in two forms, either as a `String`
 variable-length argument or a `Map`. For example,
@@ -1213,7 +1213,7 @@ writing the body of HTTP requests and responses via `InputStream` and `OutputStr
 ``HttpMessageConverter``'s are used on the client side, e.g. in the `RestTemplate`, and
 also on the server side, e.g. in Spring MVC REST controllers.
 
-Concrete implementations for the main media (mime) types are provided in the framework
+Concrete implementations for the main media (MIME) types are provided in the framework
 and are registered by default with the `RestTemplate` on the client-side and with
 `RequestMethodHandlerAdapter` on the server-side (see
 <>).
@@ -5601,9 +5601,8 @@ exception hierarchy.
 
 The `org.springframework.mail.javamail.JavaMailSender` interface adds specialized
 __JavaMail__ features such as MIME message support to the `MailSender` interface (from
-which it inherits). `JavaMailSender` also provides a callback interface for preparation
-of JavaMail MIME messages, called
-`org.springframework.mail.javamail.MimeMessagePreparator`
+which it inherits). `JavaMailSender` also provides a callback interface for preparing
+a 'MimeMessage', called `org.springframework.mail.javamail.MimeMessagePreparator`.
 
 
 
@@ -5726,23 +5725,17 @@ callback interface. Please note in this case that the `mailSender` property is o
 		}
 
 		public void placeOrder(final Order order) {
-
 			// Do the business calculations...
-
 			// Call the collaborators to persist the order...
 
 			MimeMessagePreparator preparator = new MimeMessagePreparator() {
-
 				public void prepare(MimeMessage mimeMessage) throws Exception {
-
 					mimeMessage.setRecipient(Message.RecipientType.TO,
 							new InternetAddress(order.getCustomer().getEmailAddress()));
 					mimeMessage.setFrom(new InternetAddress("mail@mycompany.com"));
-					mimeMessage.setText(
-							"Dear " + order.getCustomer().getFirstName() + " "
-								+ order.getCustomer().getLastName()
-								+ ", thank you for placing order. Your order number is "
-								+ order.getOrderNumber());
+					mimeMessage.setText("Dear " + order.getCustomer().getFirstName() + " " +
+							order.getCustomer().getLastName() + ", thanks for your order. " +
+							"Your order number is " + order.getOrderNumber() + ".");
 				}
 			};
 
@@ -5858,10 +5851,10 @@ along with an inline image.
 
 [WARNING]
 ====
-Inline resources are added to the mime message using the specified `Content-ID` (
-`identifier1234` in the above example). The order in which you are adding the text and
-the resource are __very__ important. Be sure to __first add the text__ and after that
-the resources. If you are doing it the other way around, it won't work!
+Inline resources are added to the `MimeMessage` using the specified `Content-ID`
+(`identifier1234` in the above example). The order in which you are adding the text
+and the resource are __very__ important. Be sure to __first add the text__ and after
+that the resources. If you are doing it the other way around, it won't work!
 ====