zoukankan      html  css  js  c++  java
  • 报错

    报错:

    2019-05-31 11:38:42.645 WARN 18756 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class net.aaron.demo.domain.JsonData]

    1.原因:这是因为springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖。

      2.解决步骤:

        手动添加jackson依赖到pom.xml文件中

    复制代码
      <properties>
        <jackson.version>2.5.4</jackson.version>
      </properties> 
    
      <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>
    复制代码

      如果还是没有解决,则进行以下步骤

      在springmvc配置文件中进行如下配置

    <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>
  • 相关阅读:
    数据库调优2
    数据库调优
    SQL优化
    支付宝/阿里面试题
    Servlet 工程 web.xml 中的 servlet 和 servlet-mapping 标签 《转载》
    《转载》struts旅程《2》
    《转载》struts旅程《1》
    jsp 自定义标签
    body-content取值的意义
    jsp页面中jstl标签详解
  • 原文地址:https://www.cnblogs.com/aaronRhythm/p/10954641.html
Copyright © 2011-2022 走看看