Search code examples
javaspring-mvcjacksonmultimap

@RequestBody can not read MultiMap


I am trying to use MultiValueMap (implementation of MultiMap) from apache collections. I am using Spring MVC's @RequestBody annotation. However, I keep getting HTTPMediaTypeNotSupportedException. When I change the implementation to use Map of Map from Java Util, it works fine.

Any clue? Is Jackson API unable to work with anything other than core JDK Types?


Solution

  • A @RequestBody parameter is converted using HttpMessageConverter. For MultiValueMap you should register a custom converter. For more details, check this and this.