第一种方法,参考链接,参考链接
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<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>
</mvc:annotation-driven>
第二种方法。参考文章。 在你要输出的数据的类加上
@JsonSerialize(
include=
JsonSerialize.
Inclusion.
NON_NULL)
转载请注明原文地址: https://www.6miu.com/read-25632.html