If it doesn’t work for you to change the jar package like this, see here No converter found for return value of type:

I believe that when you encounter errors with what you wrote, search Baidu, but you can't find a solution. In fact, it is only a small problem, but Baidu tells you such a solution, causing you to go wrong.

This question, if you configure spring-mvc.xml

<!-- Enable automatic scanning of annotation configuration (for converting objects to JSON) --> 
<mvc:annotation-driven></mvc:annotation-driven>

Then it will help you convert by default. If there is any jar conflict, it is best to directly import

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

This jar package will automatically find and install the corresponding version of the jar for you.

So, here comes the topic!

The problem must be that you didn’t pay attention, or you accidentally forgot to configure the web.xml to read the corresponding xml

Go and see your web.xml configuration, have you read the spring-mvc.xml file

Configurations like this are in 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>

This problem, sometimes Baidu feels that it’s all ignorant, incomprehensible, and misleading in the end! ! !

Guess you like

Origin blog.csdn.net/qq_41520636/article/details/84896227