zoukankan      html  css  js  c++  java
  • fastjson与spring mvc整合的配置

    fastjson 是阿里巴巴开发的开源json解析组件,方便于通过java来生成和解析json格式的字符串和对象。


    fastjson可以对Spring的返回数据进行json转换(SpringMVC的@ResponseBody注释)

    以下附上与spring mvc整合的xml配置:

    <mvc:annotation-driven>
    		  <mvc:message-converters register-defaults="true">
    			<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">  
    			  <property name="supportedMediaTypes" value="application/json"/>
    			  <!--设置fastjson特性-->
    			  <property name="features">
    				<array>
    				  <!--设置null值也要输出,fastjson默认是关闭的-->
    				  <value>WriteMapNullValue</value>
    				  <!--设置使用文本方式输出日期,fastjson默认是long-->
    				  <value>WriteDateUseDateFormat</value>
    				</array>
    			  </property>
    			</bean>
    		  </mvc:message-converters>  
    		</mvc:annotation-driven>


  • 相关阅读:
    struts-spring 整合
    Spring与Struts2的整合
    three.js 3d 智慧园区
    前端框架理解
    Flutter仿照airbnb创建app
    软件、语言的安装
    python功能
    python创建项目
    安装python
    mysql的安装和使用
  • 原文地址:https://www.cnblogs.com/catgwj/p/7503298.html
Copyright © 2011-2022 走看看