HTTP Status 406 --- not acceptable according to the request "accept" headers

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.

使用以下方案解决

springmvc json配置方案

Spring4.1.0

使用<annotation-driven />MVC配置方法。

在pom.xml中增加

 1      <dependency>
 2             <groupId>com.fasterxml.jackson.core</groupId>
 3             <artifactId>jackson-core</artifactId>
 4             <version>2.4.3</version>
 5         </dependency>
 6         <dependency>
 7             <groupId>com.fasterxml.jackson.core</groupId>
 8             <artifactId>jackson-databind</artifactId>
 9             <version>2.4.3</version>
10         </dependency>
11         <dependency>
12             <groupId>com.fasterxml.jackson.core</groupId>
13             <artifactId>jackson-annotations</artifactId>
14             <version>2.4.3</version>
15         </dependency>

controller方法中增加@org.springframework.web.bind.annotation.ResponseBody注解

可以解决标题中的问题

时间: 2024-08-16 17:47:38

HTTP Status 406 --- not acceptable according to the request "accept" headers的相关文章

浏览器报406 错误:The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request &quot;accept&quot; headers

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers 网上关于这个问题有很多说法,有的说spring mvc版本问题的,有说jackson jar包问题问题的,试了下都不可以, 这里的解决方法参考: https://www.cn

解决The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request &quot;accept&quot; headers.

SpringMVC中当在浏览器中输入对应的MappingUrl时,报The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers. 错误的意思是:说是指定的资源已经找到,但它的MIME类型和客户在Accpet头中所指定的不兼容 @Res

HTTP Status 406 – Not Acceptable

前端调用这个方法报错: HTTP Status 406 – Not Acceptable Type Status Report Description The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the re

spring mvc 406 (Not Acceptable) json转换错误

spring mvc通过@RequestMapping("/register")和@ResponseBody返回json格式的字符串时出现如下异常: The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers. 控

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 @ResponseBody返回json 报406 not acceptable

今天在做springmvc的@ResponseBody返回json的例子时,碰到了这样一个问题"406 (Not Acceptable)",百度之后发现在缺了一个依赖包jackson-databind. 1.spring-mvc.xml配置文件 2.pom.xml文件 [email protected]代码

Spring4 MVC json问题(406 Not Acceptable)

最近使用spring4.0的Mvc,json请求时,客户端报错,406 Not Acceptable 解决方法一: 1.导入第三方的jackson包,jackson-mapper-asl-1.9.7.jar和jackson-core-asl-1.9.7.jar. 2.Spring配置文件添加: [html]  view plain copy <mvc:annotation-driven/> !-- 避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id=&quo

Spring SpringMvc 406 Not Acceptable

406 Not Acceptable 缺少转换依赖的jar包,设置了@ResponseBody,要把对象转换成json格式. 解决方法: pom.xml文件增加 <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-asl</artifactId> <version>1.8.9</version> </depende

调用odata返回406 not acceptable解决方案

调用odata返回406 not acceptable解决方案 在web api项目中使用odata时,总是返回406 not acceptable 根据http://stackoverflow.com/questions/26676879/webapi-and-odatacontroller-return-406-not-available和http://stackoverflow.com/questions/26676879/webapi-and-odatacontroller-return