如果不管你这么换jar包都不行,看这里No converter found for return value of type:

相信大家对于自己写的东西,遇到错误,搜索百度,却始终找不到解决方案,其实只是很小的问题,但是百度却告诉你这样的解决方案,致使你跑偏了方向。

这个问题,如果你spring-mvc.xml配置了

<!-- 开启注解  配置自动扫描( 用于将对象转换为 JSON) -->
<mvc:annotation-driven></mvc:annotation-driven>

那么会默认帮你转换的,还有什么jar冲突,最好直接导

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.7</version>
</dependency>

这个jar包,会自动帮你把相应版本的jar找到安装好。

那么,正题来了!

出问题的地方,一定是你不注意,或者不小心忘记了配置web.xml中读取相应xml

快去看看你web.xml的配置,有没有读取spring-mvc.xml文件

像这类的配置在web.xml中

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml,classpath:spring-mvc.xml</param-value>
</context-param>
<!-- 配置DispatcherServlet -->
<servlet>
    <servlet-name>seckill-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- 配置springMVC需要加载的配置文件
         spring-dao.xml,spring-service.xml,spring-web.xml
         Mybatis - > spring -> springmvc
     -->
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml,classpath:spring-mvc.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>seckill-dispatcher</servlet-name>
    <!-- 默认匹配所有的请求 -->
    <url-pattern>/</url-pattern>
</servlet-mapping>

这个问题,真的有时候百度感觉全是牛头不马嘴,不知所云,到头来全是误导!!!

猜你喜欢

转载自blog.csdn.net/qq_41520636/article/details/84896227