Spring request parameter parsing
<p>Can someone please explain the following behaviour:</p>

<p>Given the following HTTP GET request<br>
<code>/test?q=queryString&amp;map[one]=val&amp;map[two]=val2&amp;map[three]=val3</code></p>

<p>why does this <code>Controller</code> method</p>

<pre><code>@RequestMapping(value = "/test")
public ResponseEntity&lt;Void&gt; test(String q, Map&lt;String, String&gt; map) {
    log.info("Q: " + q);
    log.info("Map: " + map);

    return ResponseEntity.noContent().build();
}
</code></pre>

<p>result in</p>

<pre><code>Q: queryString
Map: {}
</code></pre>

<p>whereas if I wrap both parameters in a so-aptly named <code>Wrapper</code> class</p>

<pre><code>public class Wrapper {

    private String q;

    private Map&lt;String, String&gt; map;

    //getters &amp; setters
}
</code></pre>

<p>and refactor the <code>Controller</code> method so</p>

<pre><code>@RequestMapping(value = "/test")
public ResponseEntity&lt;Void&gt; test(Wrapper wrapper) {
    log.info("Q: " + wrapper.getQ());
    log.info("Map: " + wrapper.getMap());

    return ResponseEntity.noContent().build();
}
</code></pre>

<p>the result is as follows:</p>

<pre><code>Q: queryString
Map: {one=val, two=val2, three=val3}
</code></pre>

<p>Why does <strong>Spring</strong> only bind the <code>map</code> variable values if it's contained inside a wrapper object?</p>

<p><strong>EDIT</strong></p>

<p>Looking at <code>@RequestParam</code> <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/bind/annotation/RequestParam.html" rel="nofollow">JavaDoc</a> it states</p>

<blockquote>
  <p><strong>If the method parameter is <code>Map&lt;String, String&gt;</code> or <code>MultiValueMap&lt;String, String&gt;</code> and a parameter name is not specified, then the map parameter is populated with all request parameter names and values.</strong></p>
</blockquote>

<p>But adding <code>@RequestParam(name = "map")</code> to the <code>map</code> variable doesn't change anything. It's still empty.</p>