異常
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