Could not find acceptable representation

引起的原因: 
   由于设置了@ResponseBody,要把对象转换成json格式,缺少转换依赖的jar包,故此错。

解决办法:

1 <dependency>
2             <groupId>org.codehaus.jackson</groupId>
3             <artifactId>jackson-core-asl</artifactId>
4         </dependency>
5         <dependency>
6             <groupId>org.codehaus.jackson</groupId>
7             <artifactId>jackson-mapper-asl</artifactId>
8         </dependency>

加入依赖的jar,jackson-core-asl-1.9.12.jar,jackson-mapper-asl-1.9.12.jar问题解决。

参考博客:http://jadethao.iteye.com/blog/1926525

Could not find acceptable representation,布布扣,bubuko.com

时间: 2024-10-02 08:10:38

Could not find acceptable representation的相关文章

Spring3.0 Could not find acceptable representation 解决方案

在使用spring3.0.5 mvc开发时,进行json接口数据开发,使用JSONObject.fromObject(object)返回json数据.遇到“org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation”错误. 解决方案1: @ResponseBody 方法的返回类型由JSONObject改为 Object, return时直接返回Objec

关于&quot;Could not find acceptable representation&quot;错误

在项目中调用一个第三方服务,第三方服务是用Spring Boot写成的.结果调用时返回"Could not find acceptable representation"错误. 经过调查和搜索,除了网上查到的其他方案之外,有可能是客户端Header参数Accept没有设置或者Accept设置的值在服务端不支持导致的,例如服务端自定义Accept值,而客户端没有传:或者传错了.

SpringMVC异常报406 (Not Acceptable)的解决办法

使用SpsringMVC,使用restEasy调试,controller请求设置如下: Java代码   @RequestMapping(value="/list",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<EditTimeout> list(){ List<EditTimeout> list = editImpl.s

springMVC 解决ajax请求的406错误

直入主题-- 页面表单异步提交:$.post('<%=request.getContextPath()%>/web/register.html', $(form).serialize(), function(data){...}); java后台springMVC的controller接受请求: @RequestMapping("register") @ResponseBody public Map<String, String> register(HttpSe

springmvc+json

1.在写我的springmvc demo时,由于要向前台返回相关信息,于是设置了@ResponseBody,但是要把对象转换成json格式,我却没有在xml文件里配置,所以报如下错误:HttpMediaTypeNotAcceptableException: Could not find acceptable representation.于是采用默认配置,即曾经号称“史上最快json”的Jackson <!-- 启用spring mvc 注解--> <mvc:annotation-dri

springmvc4开发rest

Spring MVC 4 RESTFul Web Services CRUD Example+RestTemplate Created on: August 11, 2015 | Last updated on: March 12, 2017 websystiqueadmin In this post we will write a CRUD Restful WebService using Spring MVC 4, and write a REST client with RestTempl

The resource identified by this request is only capable of generating responses with characteristics

[转]今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常: The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers (). 从网上查了下,说是让配置下json转化bean: <bean

SpringMVC_The resource identified by this request is only capable of generating responses with characteristics

今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常: The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers (). 从网上查了下,说是让配置下json转化bean: [html] view

Spring MVC 3.x 版本使用 @ResponseBody 返回乱码

由于万恶的Spring MVC 默认返回编码 是 ISO-8859-1, 使用如下配置, 可以将编码专为UTF-8, <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <bean class="o