no suitable HttpMessageConverter found for response type

前端 未结 10 1765
深忆病人
深忆病人 2020-11-30 02:33

Using spring, with this code :

List> messageConverters = restTemplate.getMessageConverters();
for(HttpMessageConverter ht         


        
10条回答
  •  [愿得一人]
    2020-11-30 02:54

    Or you can use

    public void setSupportedMediaTypes(List supportedMediaTypes)

    method which belongs to AbstractHttpMessageConverter, to add some ContentTypes you like. This way can let the MappingJackson2HttpMessageConverter canRead() your response, and transform it to your desired Class, which on this case,is ProductList Class.

    and I think this step should hooked up with the Spring Context initializing. for example, by using

    implements ApplicationListener { ... }

提交回复
热议问题