.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]


當想要返回的是json數據,produces寫的"text/plain",會報錯

@RequestMapping(value = "/getDynamicByDynamicId1",produces = "text/plain")
@ResponseBody
public Dynamic getDynamicByDynamicId1(){
System.out.println();
return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
}

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Nov 21 15:01:12 CST 2019
There was an unexpected error (type=Not Acceptable, status=406).
Could not find acceptable representation
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
 
改為
@RequestMapping(value = "/getDynamicByDynamicId1",produces = "application/json")
@ResponseBody
public Dynamic getDynamicByDynamicId1(){
System.out.println();
return dynamicMapper.getDynamicByAnnotationFromDynamicId(1l);
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM