HttpMediaTypeNotAcceptableException after upgrading to Spring 3.2

前端 未结 4 1876
孤独总比滥情好
孤独总比滥情好 2021-02-08 15:23

After upgrading my Spring MVC application to Spring 3.2 I\'m getting the following exception when accessing some of my URLs:

org.springframework.web.HttpMediaTyp         


        
4条回答
  •  我寻月下人不归
    2021-02-08 16:00

    You need to add a proper MessageConverter to your configuration, along with one you might already have for Jackson.

    e.g. in your subclass of WebMvcConfigurerAdapter:

    @Override
    public void configureMessageConverters(final List> converters) {
        converters.add(new StringHttpMessageConverter());
    }
    

    When you still keep the favorPathExtension option turned on, you won't require a produces parameter as well, your controller will return application/javascript.

    The hints in Aleksanders answer actually did not help me getting rid of the 406 when I had the same problem.

提交回复
热议问题