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

浙公网安备 33010602011771号