springMVC请求出现406错误

来源:互联网 发布:网络文学作品论文 编辑:程序博客网 时间:2024/06/07 06:20

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">1,项目一直用的spring 3.2.3版本+jackson 1.9.11版本。请求一直没有问题</span>

2,今天把spring版本升到4.1以上的版本就出现了问题

报错信息:

<pre name="code" class="java"> Resolving exception from handler [public java.lang.Object com.wulongyuan.controller.DemoController.test()]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation Resolving exception from handler [public java.lang.Object com.wulongyuan.controller.DemoController.test()]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representationResolving exception from handler [public java.lang.Object com.wulongyuan.controller.DemoController.test()]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representationResolving exception from handler [public java.lang.Object com.wulongyuan.controller.DemoController.test()]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representationResolving exception from handler [public java.lang.Object com.wulongyuan.controller.DemoController.test()]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representationDE
</pre><p></p><pre>
3,首先我的配置文件是没有问题的 因为之前都能用,只是把版本改了而已

让后就去看Spring官方文档  发现sping4.已经 对jackson1.9不支持了,为了测试,我将我spring的版本改回3.2+的版本。发现正常通过。因此又将版本改回,然后把jaskson的版本改为2.5

  <jackson.version>2.5.0</jackson.version> <dependency>                <groupId>com.fasterxml.jackson.core</groupId>                <artifactId>jackson-core</artifactId>                <version>${jackson.version}</version>            </dependency>            <dependency>                <groupId>com.fasterxml.jackson.core</groupId>                <artifactId>jackson-databind</artifactId>                <version>${jackson.version}</version>            </dependency>


0 0
原创粉丝点击