org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio

时间:2015-02-26 18:39:14   收藏:0   阅读:1961
@RequestMapping(value = "/enumType/importData",method = RequestMethod.POST, produces =  "text/html;charset=UTF-8")
@ResponseBody
public String importData(HttpServletRequest request,
                         @RequestParam("enumId") Long enumId)
{

     return mapper.writeValueAsString(dataMap);
}





// 运行之后,出现如下错误信息: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio 
// 这是由于 produces 参数配置错误造成的,本意是想返回 json 格式数据,而header确配置成了 text/html 格式,所以出错了。
// 改成 json 格式的 header 就可以了。
@RequestMapping(value = "/enumType/importData",method = RequestMethod.POST, produces =  "text/html;charset=UTF-8")

原文:http://blog.csdn.net/cjc921/article/details/43954505

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!