一、背景

  在搭建一套Spring+SpringMVC+Mybatis(SSM)的环境(搭建步骤会在以后博客中给出),结果运行 程序时,适用@ResponseBody注解进行返回List<对象>的json数据时出现了:nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList错误,就细细分析了下,而后解决了该问题,先拿来备份和分享!

二、框架搭建环境

  1.jdk 1.7

  2.maven 3.3.9

  3.spring 4.2.6.RELEASE

  4.springmvc 4.2.6.RELEASE

  5.mybatis 3.2.8

三、错误原因及解决步骤

  1.原因:这是因为springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖。

  2.解决步骤:

    手动添加jackson依赖到pom.xml文件中

<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>

如果还是没有解决,则进行以下步骤

在springmvc配置文件中进行如下配置

<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven>

这样我们就解决了该问题。

解决Spring MVC报No converter found for return value of type:class java.util.ArrayList问题的更多相关文章

  1. 解决springmvc报No converter found for return value of type: class java.util.ArrayList问题

    一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...

  2. SSM报错:No converter found for return value of type: class java.util.ArrayList at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverter

    我使用的是SSM框架,是在编写测试RESTFUL接口的时候出现, @RequestMapping(value = "/selectAll", method = RequestMet ...

  3. 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList问题

    在spring + springmvc + mybatis框架中,我们配置接口对外返回json格式,但是报如下错误: 24-Oct-2017 17:42:23.495 严重 [http-nio-808 ...

  4. 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList的问题

    一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...

  5. 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList这个问题

    今天使用SSM框架,用@ResponseBody注解,出现了这个问题 java.lang.IllegalArgumentException: No converter found for return ...

  6. 解决No converter found for return value of type: class java.util.ArrayList

    十一月 02, 2018 7:37:44 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() f ...

  7. 【Spring】No converter found for return value of type: class java.util.ArrayList

    错误信息: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for ret ...

  8. $.ajax函数调接口,报异常No converter found for return value of type: class java.util.ArrayList

    接口正常执行,返回给前端后报服务器500异常,异常详情: org.springframework.http.converter.HttpMessageNotWritableException: No ...

  9. Idea中:No converter found for return value of type: class java.util.ArrayList:Json格式转换问题

    1.在搞SSM框架的时候,前端发送请求后,显示如下错误. @ResponseBody注解进行返回List<对象>的json数据时出现 nested exception is java.la ...

随机推荐

  1. ubuntu1604 安装samba

    ubuntu1604 安装samba sudo apt-get install samba 更改/etc/samba/smb.conf添加[share]comment = sharepath = /h ...

  2. Screen 常用命令+VNC 启动停止命令总结

    screen -S 名称:创建一个新的会话 screen -r 会话ID:恢复一个Detach状态的会话 screen -xr 会话ID:强制恢复一个Attach状态的会话,常用于掉线时上次的会话没有 ...

  3. react篇章-React 组件-复合组件

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

  4. pycharm的安装教程及大坑

    在根据网上的教程创建新工程后,发现不能调用第三方库,网上大多给的是print('hello world'),己适python解释器用的pycharm默认的也不能发现错误.后来浏览了一篇文章才恍然大悟, ...

  5. 【交叉染色法判断二分图】Claw Decomposition UVA - 11396

    题目链接:https://cn.vjudge.net/contest/209473#problem/C 先谈一下二分图相关: 一个图是二分图的充分必要条件: 该图对应无向图的所有回路必定是偶环(构成该 ...

  6. here with you

    Here With You - Asher Book To all my friends对我所有好友来讲The night is young夜未央The music's loud乐未殇They pla ...

  7. RxSwift 系列(九)

    前言 看完本系列前面几篇之后,估计大家也还是有点懵逼,本系列前八篇也都是参考RxSwift官方文档和一些概念做的解读.上几篇文章概念性的东西有点多,一时也是很难全部记住,大家脑子里面知道有这么个概念就 ...

  8. android 网络

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha android - async - http 安卓 异步 超文本传输协议 xUtil a ...

  9. FFTW3学习笔记3:FFTW 和 CUFFT 的使用对比

    一.流程 1.使用cufftHandle创建句柄 2.使用cufftPlan1d(),cufftPlan3d(),cufftPlan3d(),cufftPlanMany()对句柄进行配置,主要是配置句 ...

  10. [BZOJ5427]最长上升子序列

    考虑O(n log n)的LIS求法,dp[i]表示到目前为止,长度为i的LIS的末尾最小是多少. 当当前数确定时直接用LIS的求法更新dp数组,当不确定时,由于这个数可以是任意数,所以可以接在任意上 ...