简体   繁体   English

全局如何忽略具有重复响应的Null Fields?

[英]How globally ignore Null Fields with restesy response?

I use JBoss EAP 7.1 with JAVA EE. 我使用JBoss EAP 7.1和JAVA EE。 I can exclude null fields in response using @JsonInclude(JsonInclude.Include.NON_NULL) annotation under class all filed. 我可以在类all all @JsonInclude(JsonInclude.Include.NON_NULL)下使用@JsonInclude(JsonInclude.Include.NON_NULL)注释排除null字段。 Does exist way to exclude globally (in all project) null values in all objects that resteasy return in response, for example here : 是否存在排除全局(在所有项目中)空值的方法,这些空值在resteasy返回响应中返回,例如:

Response.status(Response.Status.OK).entity(objet).build()

You need to configure ObjectMapper instance in your app: 您需要在应用中配置ObjectMapper实例:

ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM