zoukankan      html  css  js  c++  java
  • (HttpMessageNotWritableException ) No converter found for return value of type xxxx

    最近在家没事儿,写写代码玩,用了Maven构建SSM项目,结果提示如下信息

    org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.lcy.pojo.User
    【原因】找不到返回值类型的转换器,找了好久发现controller返回的是json格式数据

    【方案】在maven的pox.xml中只引入Json的依赖时,只引入了“jackson-core”;没有引入 “jackson-databind”,添加了依赖后问题解决了。
    【提示】当controller标记@ResponseBody后,会用解析器去解析Controller的返回值,解析器会去寻找SpringMvc中注册的HttpMeesageConverter接口的实现类,结果因为没有添加对应的依赖,所以
    就找不到Json类型的转换器了,添加依赖后就正常了。



    【正确的依赖】
    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
            <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.8</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>2.9.8</version>
            </dependency>





    
    
  • 相关阅读:
    python中的time模块
    CSS 布局
    8 Function类型
    2 node 核心
    1 node 简介
    13 对象
    JS 算法一
    JS 模块化
    1 谈谈section标签
    JS 练习一
  • 原文地址:https://www.cnblogs.com/ywtk/p/10490598.html
Copyright © 2011-2022 走看看