首页 > 编程语言 > 详细

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

时间:2019-11-21 16:38:35      阅读:1285      评论:0      收藏:0      [点我收藏+]

当想要返回的是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);
}

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

原文:https://www.cnblogs.com/sunupo/p/11905763.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!