Spring 3.x JSON status 406 “characteristics not acceptable according to the request ”accept“ headers ()”

后端 未结 14 1464
太阳男子
太阳男子 2020-12-13 01:50

Upon trying to get my response in JSON using Spring 3.x, I get the 406 error \"The resource identified by this request is only capable

14条回答
  •  旧时难觅i
    2020-12-13 02:39

    Thank you for sharing you experience.I experienced the same problem and it works for me using configuration as show below:

    1. Spring MVC Version : 3.2.5.RELEASE
    2. Apache-tomcat-6.0.24
    3. JDK1.6
    4. jackson-core-asl-1.9.10.jar
    5. jackson-mapper-asl-1.9.10.jar

    Spring MVC Config File:

    
    
    
        
    
    

    Model class : Country.java

     private Integer countryId;
     private String name;
     //public setters and getters
    

    Controller Method:

    @RequestMapping(value = "/get_country_json",method = RequestMethod.GET)
    @ResponseBody
    public Country getCountry()
    

    Deployment Descriptor(web.xml)

     
        dispatcher
        org.springframework.web.servlet.DispatcherServlet
        1       
    
    
        dispatcher
        *.htm
    
    

    URL Requested to call controller method: /SpringCURDApp/get_country_json.htm

    I hope this can help someone.

提交回复
热议问题