org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

异常

org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

原因之一(自我感觉)

设定的response的contentType同实际controller层返回的对象类型不一致。

@ResponseBody
@GetMapping(value = "xxx", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public Boolean test(){
    return true;
}
注意点
  • @ResponseBody 需存在,才可复现。(可以在Controller Class上,如果不存在,会直接走视图解析器)
  • produces定义了 contentTypeapplication/octet-stream,实际返回了true
produces 用于指定response的类型和编码
posted @ 2019-01-04 17:44  Mr.Zhongzz  阅读(20165)  评论(0编辑  收藏  举报