返回博主主页

.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);
}
posted @ 2019-11-21 15:04  懒惰的星期六  阅读(14817)  评论(0编辑  收藏  举报

Welcome to here

主页