Spring 4.1.1 RELEASE and @ResponseBody return HTTP 406

后端 未结 3 631
抹茶落季
抹茶落季 2020-12-10 13:27

I am using @ResponseBody to return Json object in Spring MVC. It works as expected on release 4.0.7 and 3.2.11, but it returns HTTP status 406 when I try to use the latest S

3条回答
  •  悲&欢浪女
    2020-12-10 14:33

    I was struggling with similar issue migrating from 3.2 to spring 4.2. Was getting

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type:

    posting it here so people can find it by exception name :) It took me half a day to find this article. Thanks @Vito and @Aias

    Combination of both previous answers work as well, if you do not want register custom contentNegotiationManager you can do following:

    remove all jackson dependencies from

    pom.xml

    and use latest one

    
        com.fasterxml.jackson.jaxrs
        jackson-jaxrs-base
        2.6.1
    
    

    servlet.xml

    
        
            
            
        
    
    

提交回复
热议问题