@@ -0,0 +1,2545 @@
+package com.royalrangers.configuration;%0A%0Aimport java.io.IOException;%0A%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.data.domain.Page;%0Aimport org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;%0Aimport org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;%0A%0Aimport com.fasterxml.jackson.annotation.JsonInclude.Include;%0Aimport com.fasterxml.jackson.core.JsonGenerator;%0Aimport com.fasterxml.jackson.core.JsonProcessingException;%0Aimport com.fasterxml.jackson.databind.JsonSerializer;%0Aimport com.fasterxml.jackson.databind.MapperFeature;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.SerializerProvider;%0A%0A@Configuration%0Apublic class JacksonAdapter extends WebMvcConfigurerAdapter %7B%0A%0A    @Bean%0A    public Jackson2ObjectMapperBuilder jacksonBuilder() %7B%0A        return  new Jackson2ObjectMapperBuilder()%0A                .failOnUnknownProperties(false)%0A                .serializationInclusion(Include.NON_EMPTY)%0A                .serializerByType(Page.class, new JsonPageSerializer());%0A%0A    %7D%0A%0A    public class JsonPageSerializer extends JsonSerializer%3CPage%3E %7B%0A%0A        @Override%0A        public void serialize(Page page, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException %7B%0A            ObjectMapper om=new ObjectMapper()%0A                    .disable(MapperFeature.DEFAULT_VIEW_INCLUSION)%0A                    .setSerializationInclusion(Include.NON_EMPTY);%0A            gen.writeStartObject();%0A            gen.writeFieldName(%22size%22);%0A            gen.writeNumber(page.getSize());%0A            gen.writeFieldName(%22number%22);%0A            gen.writeNumber(page.getNumber());%0A            gen.writeFieldName(%22totalElements%22);%0A            gen.writeNumber(page.getTotalElements());%0A            gen.writeFieldName(%22last%22);%0A            gen.writeBoolean(page.isLast());%0A            gen.writeFieldName(%22totalPages%22);%0A            gen.writeNumber(page.getTotalPages());%0A            gen.writeObjectField(%22sort%22, page.getSort());%0A            gen.writeFieldName(%22first%22);%0A            gen.writeBoolean(page.isFirst());%0A            gen.writeFieldName(%22numberOfElements%22);%0A            gen.writeNumber(page.getNumberOfElements());%0A            gen.writeFieldName(%22content%22);%0A            gen.writeRawValue(om.writerWithView(serializers.getActiveView())%0A                    .writeValueAsString(page.getContent()));%0A            gen.writeEndObject();%0A        %7D%0A    %7D%0A%7D%0A

Fix return empty data with JsonView on Page object.