Spring 4.1.1 RELEASE and @ResponseBody return HTTP 406

后端 未结 3 632
抹茶落季
抹茶落季 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:07

    Got it working after removing Jackson 1.* replacing with the 2.4.4 (JAXRS), which will import all the other dependencies, jackson-core, jackson-databind and jackson-annotations.

    Removed

    
        org.codehaus.jackson
        jackson-core-asl
        1.9.13
    
    
        org.codehaus.jackson
        jackson-mapper-asl
        1.9.13
    
    

    Added

    
        com.fasterxml.jackson.jaxrs
        jackson-jaxrs-base
        2.4.4
    
    

    http://www.codingpedia.org/ama/jquery-ui-autocomplete-not-working-in-spring-4-1/

    and in the servlet xml

    
    
    
         
         
         
              
                   json=application/json
                   xml=application/xml
              
         
    
    

    if the jackson annotate is imported in the class files, it should also be replaced

    Removed

    import org.codehaus.jackson.annotate.JsonIgnoreProperties

    Added

    import com.fasterxml.jackson.annotation.JsonIgnoreProperties

提交回复
热议问题