当前位置: 首页 > 工具软件 > ash.MVC > 使用案例 >

No converter found for return value of type: class com.ash.cn.pojo.SysUser

段干英杰
2023-12-01

1. 在POM中添加jackjson依赖:

<!--json-->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.10.1</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.10.1</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.10.1</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.13</version>
    </dependency>

2. 在spring-mvc.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>

注意: jackjson的 如果和spring版本不兼容,会出现找不到jackjson包中类的一场,最好都是用较为新的jar包。

 类似资料:

相关阅读

相关文章

相关问答