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 = RequestMethod.GET)
@ResponseBody
public ResponseEntity<List<User>> selectAll() {
List<User> users = this.userService.selectAll();
if (null != users && users.size() > 0) {
return ResponseEntity.ok(users);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
代码不是非常严谨,只是做测试。
访问:http://localhost:8081/selectAll
错误:
No converter found for return value of type: class java.util.ArrayList at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:187) at org.s
原因:这是因为springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖。
解决:添加相关依赖
<!--jacson支持json-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.4</version>
</dependency>
成功解决:
[{"username":"admin","password":"admin"},{"username":"zhanxuewei","password":"123456"}]
参考:https://www.cnblogs.com/hafiz/p/5812873.html
SSM报错:No converter found for return value of type: class java.util.ArrayList at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverter的更多相关文章
- $.ajax函数调接口,报异常No converter found for return value of type: class java.util.ArrayList
接口正常执行,返回给前端后报服务器500异常,异常详情: org.springframework.http.converter.HttpMessageNotWritableException: No ...
- 解决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 ...
- 解决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 ...
- 解决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 MVC报No converter found for return value of type:class java.util.ArrayList问题
一.背景 在搭建一套Spring+SpringMVC+Mybatis(SSM)的环境(搭建步骤会在以后博客中给出),结果运行 程序时,适用@ResponseBody注解进行返回List<对象&g ...
- 解决springmvc报No converter found for return value of type: class java.util.ArrayList问题
一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...
- Idea中:No converter found for return value of type: class java.util.ArrayList:Json格式转换问题
1.在搞SSM框架的时候,前端发送请求后,显示如下错误. @ResponseBody注解进行返回List<对象>的json数据时出现 nested exception is java.la ...
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList的问题
一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...
- 【Spring】No converter found for return value of type: class java.util.ArrayList
错误信息: org.springframework.http.converter.HttpMessageNotWritableException: No converter found for ret ...
随机推荐
- 常用shell命令的写法
这并不是教人怎么进行shell编程的文章,只是韦哥在工作中用到的一些简单脚本的写法.因为有些命令即使用过几次了,再次使用时仍然写不对,需要man来看下或者需要google,你也可以理解为对命令的理解不 ...
- Centos6-编译安装Redis
[root@tbwy02 ~]# cd /tools/[root@tbwy02 tools]# yum install -y wget gcc make tcl[root@tbwy02 tools]# ...
- 树莓派wiringPi经常使用的函数介绍
1.void pinMode (int pin, int mode) ; 这个函数式设置pin脚的输入和输出模式以及PWM的输入和输出模式.在wiringPi中仅仅有 pin 1 (BCM_GP ...
- AppFuse 3的乱码问题
书接上回:AppFuse 3常见问题与解决方法,一个新问题:乱码! 在3.0.0版本号下,运行mvn appfuse:full-source命令后使用mvn jetty:run启动工程,页面上就出现了 ...
- Storm项目:流数据监控1《设计文档…
博客公告: (1)本博客全部博客文章搬迁至<博客虫>http://blogchong.com/ (2)文章相应的源代码下载链接參考博客虫站点首页的"代码GIT". (3 ...
- python day - 19 抽象类 接口类 多态 封装
一. 抽象类接口类即制定一个规范 特点: 1.不可被实例化. 2.规范子类当中必须事先某个方法. 3.在python中有原生实现抽象类的方法,但没有原生实现接口类的方法. 例题:制定一个规范就是,子类 ...
- HDU 6040 Hints of sd0061 nth_element函数
Hints of sd0061 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired ...
- Erlang Garbage Collector
Erlang Garbage Collector | Erlang Solution blog https://www.erlang-solutions.com/blog/erlang-garbage ...
- 关于jquery中attr和prop的用法
在项目开发中,遇到过这个情况,做一个全选的功能,通过点击一个checkbox实现下面的checkbox全选,用attr设置的checked属性,只可以生效一次,再次点击就不起作用了,但确实触发了事件, ...
- Codility经典算法题之九:MissingInteger
Task description: This is a demo task. Write a function: that, given an array A of N integers, retur ...