title: Java Spring Convert whole GET Request to Custom DTO
body: <p>According to the Spring documentation, you can receive all <code>GET</code> parameters in a map like so:</p>
  
  <pre><code>@GetMapping
  public final ReturnType getAll(@RequestParam MultiValueMap&lt;String, String&gt; allRequestParams) {
      ...
  }
  </code></pre>
  
  <p>Is it possible (and how) to also accept a custom Java object instead (for which a custom <code>Converter</code> exists via subclassing <code>GenericConverter</code>) in such a way that the Converter gets the whole request map for construction of its DTO object?</p>
  
  <pre><code>@GetMapping
  public final ReturnType getAll(@RequestParam CustomDTO customObj) {
      [...]
  }
  
  [...]
  
  @Component
  public class CustomDTOConverter implements GenericConverter {
  
      @Override
      public Set&lt;ConvertiblePair&gt; getConvertibleTypes() {
          // Allow MultiValueMap.class to CustomDTO.class
          [...]
      }
  
      @Override
      public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
  
          final MultiValueMap&lt;String, String&gt; requestMap = (MultiValueMap&lt;String, String&gt;) source;
          // Construct CustomDTO from the requestMap
      }
  }
  </code></pre>
  
  <p>Trying the above snippet will fail, complaining that there is no parameter <code>customObj</code> present.</p>