bkielczewski / example-spring-mvc-jetty

79 stars 49 forks source link

Json conversion #2

Open hauter opened 8 years ago

hauter commented 8 years ago

I want to convert json to object, but I get 415 Unsupported Media Type

    @RequestMapping(value = "/", method = RequestMethod.POST)
    @ResponseBody
    public String showIndex(@RequestBody AAA aaa) {
        return "{}";
    }

How can I do that?

hauter commented 8 years ago

I solved this problem

@Configuration
@ComponentScan(basePackages = "eu.kielczewski.example")
public class AppConfig extends WebMvcConfigurerAdapter {

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(new MappingJackson2HttpMessageConverter());
        super.configureMessageConverters(converters);
    }
}