Spring Data Pagination使用JSONView不返回任何结果

Spring Data Pagination使用JSONView不返回任何结果,第1张

Spring Data Pagination使用JSONView不返回任何结果

尝试下面的代码,

@Configurationpublic class MyInterceptorConfig extends WebMvcConfigurerAdapter{    @Override    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {      MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();      ObjectMapper mapper = new ObjectMapper() {        private static final long serialVersionUID = 1L;        @Override        protected DefaultSerializerProvider _serializerProvider(SerializationConfig config) {          // replace the configuration with my modified configuration.          // calling "withView" should keep previous config and just add my changes.          return super._serializerProvider(config.withView(TravelRequestView.MyRequests.class));        }   };      mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true);      converter.setObjectMapper(mapper);      converters.add(converter);    }

尽管我不想为此功劳,但这是来自

它将检索使用jsonview(TravelRequestView.MyRequests.class)注释的实体的所有变量以及未使用jsonview注释的所有变量。如果您不想要对象的某些属性,请使用不同的视图进行注释。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5621821.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存