HttpMediaTypeNotAcceptableException after upgrading to Spring 3.2

前端 未结 4 1877
孤独总比滥情好
孤独总比滥情好 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:07

    I have a similar issue where rest call to the controller is having path variable which contains .au in path value. Spring is reading .au as file extention due to spring Content Negotiation

    REST GET call is http://localhost:8080/api/forgot-password/kk@kudeta.com.au due to .au in path variable Spring is throwing org.springframework.web.HttpMediaTypeNotAcceptableException

    We have resolved it by turning off content based negotiation

    @Configuration
    public class ContentNegotiationConfig extends WebMvcConfigurerAdapter{
        @Override
        public void configureContentNegotiation(final 
         ContentNegotiationConfigurer configurer) {
            // Turn off suffix-based content negotiation
            configurer.favorPathExtension(false);
        }
    
    }
    

提交回复
热议问题