整合SSM之springmvc 报错:No converter found for return value of type: class java.util.ArrayList
程序员文章站
2024-01-14 13:18:58
...
今天用idea整合SSM时测试报错
java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:178)
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:153)
org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:165)
org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
查阅了很多的博客资料,有说缺少getter、setter方法的,也有说缺少包的,然后我用的是阿里巴巴的依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.8</version>
</dependency>
一直不行,然后后来没办法,换成jackson试了一下
<!--jackson,把对象和json格式互转换时需要用到 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.7</version>
</dependency>
修改依赖后重新跑了一下
神奇的好了,这里记录一下,如果有同样错误的可以参考一下,亲测有效。
推荐阅读
-
整合SSM之springmvc 报错:No converter found for return value of type: class java.util.ArrayList
-
解决No converter found for return value of type: class java.util.ArrayList
-
No converter found for return value of type: class java.util.ArrayList
-
No converter found for return value of type: class java.util.ArrayList
-
【Spring】No converter found for return value of type: class java.util.ArrayList
-
关于No converter found for return value of type: class java.util.ArrayList
-
HTTP Status 500 - No converter found for return value of type: class java.util.ArrayList
-
SpringMVC 报错HTTP Status 500 - No converter found for return value of type解决方案
-
SpringMVC 访问Controller 报错:e No converter found for return value of type: class java.util.ArrayLis
-
SpringMVC 报错HTTP Status 500 - No converter found for return value of type解决方案