Spring MVC No converter found for return value of type 解决方法
2017-04-18 21:18
806 查看
1.在pom.xml中配置
在 spring mvc 的配置文件 dispatcher-servlet.xml 中配置
如果需要返回的一个对象的JSON,一定要确保相应的对象有对应的set 和 get函数,否则也会报错
<properties> <jackson.version>2.8.5</jackson.version> </properties> <!-- jackson --> <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> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${jackson.version}</version> </dependency>
在 spring mvc 的配置文件 dispatcher-servlet.xml 中配置
<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>
如果需要返回的一个对象的JSON,一定要确保相应的对象有对应的set 和 get函数,否则也会报错
type Exception report message Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList description The server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause 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:187) org.springfra b588 mework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:174) org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:132) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/8.5.11 logs.
相关文章推荐
- Spring MVC No converter found for return value of type 解决方法
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type
- No converter found for return value of type解决方法
- spring boot:No converter found for return value of type: class另类解决办法
- No converter found for return value of type: class org.json.JSONArray解决方法
- Spring MVC No converter found for return value of type
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util
- 170616、解决 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList
- 解决返回JSON时报错:No converter found for return value of type:
- 使用Spring Cloud微服务框架进行多个微服务整合时出现No converter found for return value of type:xxx异常信息
- 解决springmvc报No converter found for return value of type
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList的问题
- 解决Spring MVC报No converter found for return value of type:class java.util.ArrayList问题
- springboot错误 java.lang.IllegalArgumentException:No converter found for return value of type
- 关于java.lang.IllegalArgumentException: No converter found for return value of type: class 的问题解决
- 170524、java.lang.IllegalArgumentException: No converter found for return value of type异常解决
- 【已解决】java.lang.IllegalArgumentException: No converter found for return value of type: class java.uti
- 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.uvvvvv