springmvc返回数据转日期格式--返回字符串等

来源:互联网 发布:淘宝单机游戏店铺赚钱 编辑:程序博客网 时间:2024/06/05 20:55

这里要导包    fastjson-1.2.3.jar,处理controller返回的数据

用的是 com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter类

本例返回格式(字符串)  date = "2015-01-01 01:01:01"

<mvc:annotation-driven>

<mvc:message-converters register-defaults="false">
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
   <list>
       <value>text/html;charset=UTF-8</value>
       <value>application/json;charset=UTF-8</value>
    </list>

</property>

<!-- 定义一个时间属性,  WriteDateUseDateFormat是FastJsonHttpMessageConverter类自带的属性features中的枚举值 ,格式可看SerializerFeature类(fastjson包)-->.

<property name="features" value="WriteDateUseDateFormat"></property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>

0 0
原创粉丝点击