|
|
|
|
@ -72,6 +72,48 @@ values for the same parameter name.
@@ -72,6 +72,48 @@ values for the same parameter name.
|
|
|
|
|
When an `@RequestParam` annotation is declared as a `Map<String, String>` or |
|
|
|
|
`MultiValueMap<String, String>`, without a parameter name specified in the annotation, |
|
|
|
|
then the map is populated with the request parameter values for each given parameter name. |
|
|
|
|
The following example shows how to do so with form data processing: |
|
|
|
|
|
|
|
|
|
[tabs] |
|
|
|
|
====== |
|
|
|
|
Java:: |
|
|
|
|
+ |
|
|
|
|
[source,java,indent=0,subs="verbatim,quotes",role="primary"] |
|
|
|
|
---- |
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/pets") |
|
|
|
|
class EditPetForm { |
|
|
|
|
|
|
|
|
|
// ... |
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/process", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) |
|
|
|
|
public String processForm(@RequestParam MultiValueMap<String, String> params) { |
|
|
|
|
// ... |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ... |
|
|
|
|
} |
|
|
|
|
---- |
|
|
|
|
Kotlin:: |
|
|
|
|
+ |
|
|
|
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] |
|
|
|
|
---- |
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/pets") |
|
|
|
|
class EditPetForm { |
|
|
|
|
|
|
|
|
|
// ... |
|
|
|
|
|
|
|
|
|
@PostMapping("/process", consumes = [MediaType.APPLICATION_FORM_URLENCODED_VALUE]) |
|
|
|
|
fun processForm(@RequestParam params: MultiValueMap<String, String>): String { |
|
|
|
|
// ... |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ... |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
---- |
|
|
|
|
====== |
|
|
|
|
|
|
|
|
|
Note that use of `@RequestParam` is optional (for example, to set its attributes). |
|
|
|
|
By default, any argument that is a simple value type (as determined by |
|
|
|
|
|