JSON parse error: Can not construct instance of org.springframework.data.domain.Page:

 org.springframework.data.domain.Page:转换异常报错,解决方法,缺少实现类

JSON parse error: Can not construct instance of org.springframework.data.domain.Page:
 abstract types either need to be mapped to concrete types, have custom deserializer, or
 contain additional type information; nested exception is 
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of 
org.springframework.data.domain.Page: abstract types either need to be mapped to 
concrete types, have custom deserializer, or contain additional type information at 
[Source: java.io.PushbackInputStream@c793cf1; line: 1, column: 1]
package com.lenovo.chinaservice.pscm.iwm.utils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class RestPage implements Page {
    private PageImpl pageDelegate = new PageImpl<>(new ArrayList<>(0));

    @Override
    public List getContent() {
        return pageDelegate.getContent();
    }

    @Override
    public int getNumber() {
        return pageDelegate.getNumber();
    }

    @Override
    public int getNumberOfElements() {
        return pageDelegate.getNumberOfElements();
    }

    @Override
    public int getSize() {
        return pageDelegate.getSize();
    }

    @Override
    public Sort getSort() {
        return pageDelegate.getSort();
    }

    @Override
    public long getTotalElements() {
        return pageDelegate.getTotalElements();
    }

    @Override
    public int getTotalPages() {
        return pageDelegate.getTotalPages();
    }

    @Override
    public boolean hasContent() {
        return pageDelegate.hasContent();
    }

    @Override
    public boolean hasNext() {
        return pageDelegate.hasNext();
    }

    @Override
    public boolean hasPrevious() {
        return pageDelegate.hasPrevious();
    }

    @Override
    public boolean isFirst() {
        return pageDelegate.isFirst();
    }

    @Override
    public boolean isLast() {
        return pageDelegate.isLast();
    }

    @Override
    public Iterator iterator() {
        return pageDelegate.iterator();
    }

    @Override
    public  Page map(Converter converter) {
        return pageDelegate.map(converter);
    }

    @Override
    public Pageable nextPageable() {
        return pageDelegate.nextPageable();
    }

    @Override
    public Pageable previousPageable() {
        return pageDelegate.previousPageable();
    }

    public void setContent(List content) {
        pageDelegate = new PageImpl<>(content, null, getTotalElements());
    }


    public void setTotalElements(int totalElements) {
        pageDelegate = new PageImpl<>(getContent(), null, totalElements);
    }

    @Override
    public String toString() {
        return pageDelegate.toString();
    }
}

 

你可能感兴趣的:(PageHelper)