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.

  控制台没有任何异常信息输出,找了很久发现需要如下包:

jackson-core-asl-1.9.9-redhat-1.jar
jackson-jaxrs-1.9.9-redhat-1.jar
jackson-mapper-asl-1.9.9-redhat-1.jar
spring-web-servlet-3.1.2.RELEASE.jar 

  如果是eclipse,加入jar包以后记得刷新项目后重启。否则加入的包不一定生效。

上一篇:2. 妈呀,Jackson原来是这样写JSON的


下一篇:static关键字真能提高Bean的优先级吗?答:真能