异常
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
定义了contentType
为application/octet-stream
,实际返回了true