The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers

使用springmvc,前端发出请求时返回json格式时,报了以上错误,错误码406。

读了参考文章后,查看spring的xml配置,是支持json格式转换的


  
    
      text/html;charset=UTF-8
      application/json
    
  

接着再回到Controller的方法里,就发现了问题:第二行,把text/json改为application/json,问题解决

@ResponseBody
@GetMapping(produces = "text/json;charset=utf-8")
public ResultVO getMethod() {
    //..
}

参考文章

Spring MVC控制器用@ResponseBody声明返回json数据报406的问题

The resource identified by this request is only capable of generating responses with characteristics

你可能感兴趣的:(The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers)