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包以后记得刷新项目后重启。否则加入的包不一定生效。

时间: 2024-08-01 03:10:57

spring mvc 406 (Not Acceptable) json转换错误的相关文章

Spring MVC 学习总结(九)——Spring MVC实现RESTful与JSON(Spring MVC为前端提供服务)

 很多时候前端都需要调用后台服务实现交互功能,常见的数据交换格式多是JSON或XML,这里主要讲解Spring MVC为前端提供JSON格式的数据并实现与前台交互.RESTful则是一种软件架构风格.设计风格,而不是标准,只是提供了一组设计原则和约束条件.它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制. 一.JSON 1.1.概要 JSON(JavaScript Object Notation, JS 对象标记) 是一种轻量级的数据交换格式

我用spring mvc+mybatis整合为什么出这个错误,是不是路径错误?我是新手,请大神指教

问题描述 我用spring mvc+mybatis整合为什么出这个错误,是不是路径错误?我是新手,请大神指教 org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:JAVANewWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsstudent

Spring mvc中将bean转json的过程中Date问题

问题描述 Spring mvc中将bean转json的过程中Date问题 Spring mvc中将bean转json的过程中,date格式(yyyy-MM-dd HH:mm:ss)如果秒的最后一位为0,转后后前端页面得到的格式为yyyy-MM-dd,? HH:mm:ss这部分就没有了:例如Bean中的日期为2015-5-12 13:22:20,前端页面得到的json结果为2015-5-12 ,?如果2015-5-12 13:22:21,前端页面得到的json就是正常的?2015-5-12 13:

spring MVC 使用注解返回json

使用spring MVC框架时,如何使用注解返回json呢? Java代码   @ResponseBody       @RequestMapping(value = "/login")       public ModelAndView ajaxLogin(Model model,User user,HttpServletRequest request, HttpSession session){           String errorMessage=loginCommon(m

《精通Spring MVC 4》——1.7 错误与转码配置

1.7 错误与转码配置 还记得在没有添加控制器的时候,第一次启动应用吗?当时看到了一个有意思的"Whitelabel Error Page"输出. 错误处理要比看上去更麻烦一些,尤其是在没有web.xml配置文件并且希望应用能够跨Web服务器部署时更是如此.好消息是Spring Boot将会处理这些事情!让我们看一下ErrorMvcAutoConfiguration: ConditionalOnClass({ Servlet.class, DispatcherServlet.class

IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践

原文:IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践 最近把编辑器换成IntelliJ IDEA,主要是Eclipse中处理Maven项目很不方便,很早就听说IntelliJ IDEA的大名了,但是一直没机会试试.最近终于下载安装了,由于是新手,决定尝试个Tutorials,最终找了个熟悉点的项目,就是Getting Started with Spring MVC, Hibernate and JSON(ht

Spring MVC 更灵活的控制 json 返回

这篇文章主要讲 Spring MVC 如何动态的去返回 Json 数据 在我们做 Web 接口开发的时候, 经常会遇到这种场景. 两个请求,返回同一个对象,但是需要的返回字段并不相同.如以下场景 /** * 返回所有名称以及Id */ @RequestMapping("list") @ResponseBody public List<Article> findAllNameAndId() { return articleService.findAll(); } /** *

解决spring mvc 返回json数据到ajax报错parseerror问题

最近使用ajax接收spring mvc传过来的json数据时总是出现parseerror的错误,错误源码如下: 前端: $.ajax({ type: 'POST', url: "groupFunctionEdit", dataType: 'json', contentType: "application/json", data: JSON.stringify(functiondata), success: function(data){ alert('数据加载成功

spring mvc

作者:赵磊 博客:http://elf8848.iteye.com   目录 一.前言 二.spring mvc 核心类与接口 三.spring mvc 核心流程图 四.spring mvc DispatcherServlet说明 五.spring mvc 父子上下文的说明 六.springMVC-mvc.xml 配置文件片段讲解 七.spring mvc 如何访问到静态的文件,如jpg,js,css 八.spring mvc 请求如何映射到具体的Action中的方法 九.spring mvc