spring4和springboot过滤null属性或将null属性转为空字符串
有资料显示可以在springboot提供的application.properties中配置 spring.jackson.default-property-inclusion=non_null 我试了下,并没有什么卵用。
作用范围Bean
1. @JsonInclude(JsonInclude.Include.NON_NULL)
作用范围整个工程
1 | @Bean |
这种写法有个问题,会导致spring的Valid注解不起作用。无法使用验证框架,改进方式如下:
1 | @Bean |
spring4和springboot的null属性转为空字符串
1 | @Bean |
以上,本人请测.