From f839969b6c551b6777a5c827134956fc013d6fb5 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Thu, 29 Oct 2009 12:32:17 +0000 Subject: [PATCH] javadoc. --- .../web/client/RestTemplate.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/org.springframework.web/src/main/java/org/springframework/web/client/RestTemplate.java b/org.springframework.web/src/main/java/org/springframework/web/client/RestTemplate.java index 7210c05e36..ae5945343e 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/org.springframework.web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -55,8 +55,9 @@ import org.springframework.web.util.UriTemplate; * PUT{@link #put} any{@link #execute} * *

For each of these HTTP methods, there are three corresponding Java methods in the {@code RestTemplate}. - * Two variant take a {@code String} URI as first argument, and are capable of substituting any - * {@linkplain UriTemplate uri templates} in that URL using either a + * Two variant take a {@code String} URI as first argument (eg. {@link #getForObject(String, Class, String[])}, + * {@link #getForObject(String, Class, Map)}), and are capable of substituting any + * {@linkplain UriTemplate URI templates} in that URL using either a * {@code String} variable arguments array, or a {@code Map}. The string varargs variant expands the * given template variables in order, so that *

@@ -71,8 +72,16 @@ import org.springframework.web.util.UriTemplate;
  * String result = restTemplate.getForObject("http://example.com/hotels/{hotel}/rooms/{hotel}", String.class, vars);
  * 
* will perform a GET on {@code http://example.com/hotels/42/rooms/42}. - * Alternatively, there are {@link URI} variant methods, which do not allow for URI templates, but allow you to reuse a - * single, expanded URI multiple times. + * Alternatively, there are {@link URI} variant methods ({@link #getForObject(URI, Class)}), which do not allow for + * URI templates, but allow you to reuse a single, expanded URI multiple times. + * + *

Furthermore, the {@code String}-argument methods assume that the URL String is unencoded. This means that + *

+ * restTemplate.getForObject("http://example.com/hotel list");
+ * 
+ * will perform a GET on {@code http://example.com/hotel%20list}. As a result, any URL passed that is already encoded + * will be encoded twice (i.e. {@code http://example.com/hotel%20list} will become {@code http://example.com/hotel%2520list}). + * If this behavior is undesirable, use the {@code URI}-argument methods, which will not perform any URL encoding. * *

Objects passed to and returned from these methods are converted to and from HTTP messages by {@link * HttpMessageConverter} instances. Converters for the main mime types are registered by default, but you can also write