Skip to content

Commit df09023

Browse files
committed
Update documentation for Map arguments
Issue: SPR-12347
1 parent 4412bc6 commit df09023

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

spring-web/src/main/java/org/springframework/web/bind/annotation/MatrixVariable.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,15 @@
2727
* name-value pair within a path segment. Supported for {@link RequestMapping}
2828
* annotated handler methods in Servlet environments.
2929
*
30+
* <p>If the method parameter type is {@link java.util.Map} and a matrix variable
31+
* name is specified, then the matrix variable value is converted to a
32+
* {@link java.util.Map} assuming an appropriate conversion strategy is available.
33+
*
34+
* <p>If the method parameter is {@link java.util.Map Map&lt;String, String&gt;} or
35+
* {@link org.springframework.util.MultiValueMap MultiValueMap&lt;String, String&gt;}
36+
* and a variable name is not specified, then the map is populated with all
37+
* matrix variable names and values.
38+
*
3039
* @author Rossen Stoyanchev
3140
* @since 3.2
3241
*/

spring-web/src/main/java/org/springframework/web/bind/annotation/PathVariable.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,10 @@
2727
* variable. Supported for {@link RequestMapping} annotated handler methods in Servlet
2828
* environments.
2929
*
30+
* <p>If the method parameter is {@link java.util.Map Map&lt;String, String&gt;} or
31+
* {@link org.springframework.util.MultiValueMap MultiValueMap&lt;String, String&gt;}
32+
* then the map is populated with all path variable names and values.
33+
*
3034
* @author Arjen Poutsma
3135
* @since 3.0
3236
* @see RequestMapping

spring-web/src/main/java/org/springframework/web/bind/annotation/RequestHeader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,11 @@
2626
* Annotation which indicates that a method parameter should be bound to a web request header.
2727
* Supported for annotated handler methods in Servlet and Portlet environments.
2828
*
29+
* <p>If the method parameter is {@link java.util.Map Map&lt;String, String&gt;} or
30+
* {@link org.springframework.util.MultiValueMap MultiValueMap&lt;String, String&gt;},
31+
* or {@link org.springframework.http.HttpHeaders HttpHeaders} then the map is
32+
* populated with all header names and values.
33+
*
2934
* @author Juergen Hoeller
3035
* @since 3.0
3136
* @see RequestMapping

src/asciidoc/index.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30829,6 +30829,7 @@ multiple requests are allowed to access a session concurrently.
3082930829
<<mvc-ann-requestparam>>.
3083030830
* `@RequestHeader` annotated parameters for access to specific Servlet request HTTP
3083130831
headers. Parameter values are converted to the declared method argument type.
30832+
See <<mvc-ann-requestheader>>.
3083230833
* `@RequestBody` annotated parameters for access to the HTTP request body. Parameter
3083330834
values are converted to the declared method argument type using
3083430835
++HttpMessageConverter++s. See <<mvc-ann-requestbody>>.
@@ -30968,6 +30969,10 @@ parameter is optional by setting ++@RequestParam++'s `required` attribute to `fa
3096830969
Type conversion is applied automatically if the target method parameter type is not
3096930970
`String`. See <<mvc-ann-typeconversion>>.
3097030971

30972+
When an `@RequestParam` annotation is used on a `Map<String, String>` or
30973+
`MultiValueMap<String, String>` argument, the map is populated with all request
30974+
parameters.
30975+
3097130976

3097230977
[[mvc-ann-requestbody]]
3097330978
===== Mapping the request body with the @RequestBody annotation
@@ -31471,6 +31476,11 @@ The following code sample demonstrates how to get the value of the `Accept-Encod
3147131476
Type conversion is applied automatically if the method parameter is not `String`. See
3147231477
<<mvc-ann-typeconversion>>.
3147331478

31479+
When an `@RequestHeader` annotation is used on a `Map<String, String>`,
31480+
`MultiValueMap<String, String>`, or `HttpHeaders` argument, the map is populated
31481+
with all header values.
31482+
31483+
3147431484
[TIP]
3147531485
====
3147631486
Built-in support is available for converting a comma-separated string into an

0 commit comments

Comments
 (0)