class A {
@NotNull
@NotEmpty
String name;
B b;
//setters and getters
}
class B {
MultiValueMap<String, String> keyMultiValues;
//setters and getters
}
@RestController
class MyController {
@PostMapping(value="/test", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public String doSomething(@RequestBody @Valid A a){
//some business logic
}
}
I am getting below error due to because of using MultiValueMap in B class [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported]
Any idea, how to fix above issue?
Please change the interface to implementation on the data class as you need to precisely show to your parser which implementation he should use. In this case, you can use for example LinkedMultiValueMap.