解决Spring MVC报No converter found for return value of type:class java.util.ArrayList问题
一、背景
在搭建一套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问题的更多相关文章
- 解决springmvc报No converter found for return value of type: class java.util.ArrayList问题
一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...
- 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 ...
- 解决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 ...
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList的问题
一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...
- 解决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 ...
- 解决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 ...
- 【Spring】No converter found for return value of type: class java.util.ArrayList
错误信息: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for ret ...
- $.ajax函数调接口,报异常No converter found for return value of type: class java.util.ArrayList
接口正常执行,返回给前端后报服务器500异常,异常详情: org.springframework.http.converter.HttpMessageNotWritableException: No ...
- Idea中:No converter found for return value of type: class java.util.ArrayList:Json格式转换问题
1.在搞SSM框架的时候,前端发送请求后,显示如下错误. @ResponseBody注解进行返回List<对象>的json数据时出现 nested exception is java.la ...
随机推荐
- 安迪的第一个字典(UVa10815)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...
- JavaScript 中的原型(总则)
1. 一切函数都是对象 2. 一切对象都是由函数创建的,所有函数都是由Function创建的,每个函数都是一个Function对象. 3. 对象.__proto__ === 函数.prototype ...
- Codeforces Round #300 E - Demiurges Play Again
E - Demiurges Play Again 感觉这种类型的dp以前没遇到过... 不是很好想.. dp[u] 表示的是以u为子树进行游戏得到的值是第几大的. #include<bits/s ...
- 【转载】Picasso源码解析
原文地址:http://blog.csdn.net/u012702547/article/details/52273918 Picasso是Squareup公司出的一款图片加载框架,能够解决我们在An ...
- 初拾Java(问题一:404错误,页面找不到)
做测试尤其是想走自动化测试之路的人,怎么可以不会码代码?!怒了... 再次开始拾起Java,坚持坚持!!! 刚写了一个JSP页面,想在Myeclipse里面跑来试试,结果搞了半天出现以下错误: 试着去 ...
- Python学习之argparse
http://www.2cto.com/kf/201412/363654.html https://docs.python.org/3.4/howto/argparse.html# 一.简介: arg ...
- java console 到文件
System.setOut(new PrintStream(new FileOutputStream("c:\\temp\\test1.txt"))); System.out.pr ...
- 分割视图控制器(UISplitViewController)
这种控制器只能用于iPad,它可以在iPad屏幕中显示两个不同的场景:在横向模式下,左边显示一个表,供用户选择:用户选择表中的元素后,详细视图将显示该元素的详细信息.如果iPad被旋转到纵向模式,表将 ...
- Selenium之PhantomJS相关设置
设置PhantomJS请求头 默认情况下: from selenium import webdriver import time driver = webdriver.PhantomJS() driv ...
- Process Explorer常用操作介绍
(未获得作者本人同意,严禁转载) Process Explorer出现的背景 Process Explorer可以看成是一个加强版的任务管理器.在较早的Windows版本中,任务管理器提供的功能是非常 ...