有些model,里面很多属性是null,我们希望过滤掉为null的属性,比如 a = null, b = "kk",传递到前台的只有{"b":"kk"}
-
<mvc:annotation-driven>
-
<!-- 强化参数接收 -->
-
<mvc:argument-resolvers>
-
<bean class="org.durcframework.common.form.FormModelMethodArgumentResolver" />
-
</mvc:argument-resolvers>
-
-
<mvc:message-converters>
-
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
-
<property name="objectMapper">
-
<bean class="com.fasterxml.jackson.databind.ObjectMapper">
-
<!-- 处理responseBody 里面日期类型 -->
-
<property name="dateFormat">
-
<bean class="java.text.SimpleDateFormat">
-
<constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss" />
-
</bean>
-
</property>
-
<!-- 为null字段时不显示 -->
-
<property name="serializationInclusion">
-
<value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value>
-
</property>
-
</bean>
-
</property>
-
</bean>
-
</mvc:message-converters>
-
</mvc:annotation-driven>
-
<mvc:message-converters register-defaults="true">
-
<bean
-
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
-
<property name="prefixJson" value="false" />
-
<property name="supportedMediaTypes" value="application/json" />
-
<property name="objectMapper">
-
<bean class="com.fasterxml.jackson.databind.ObjectMapper">
-
<property name="serializationInclusion">
-
<value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value>
-
</property>
-
</bean>
-
</property>
-
</bean>
-
</mvc:message-converters>
阅读(4109) | 评论(0) | 转发(0) |