[Java Spring] Built-in page and sorting

package com.example.ec.repo;

import com.example.ec.domain.Difficulty;
import com.example.ec.domain.Region;
import com.example.ec.domain.Tour;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.*;


public interface TourRepository extends PagingAndSortingRepository<Tour, Integer> {

    // without paging
    // /tours/search/findByTourPackageCode?code=CC
    List<Tour> findByTourPackageCode(@Param("code") String codee);

    // with paging and sorting
    // /tours/search/findByTourPackageCode?code=CC&size=3&sort=title,asc
    Page<Tour> findByTourPackageCode(@Param("code") String code, Pageable pageable);
}
原文地址:https://www.cnblogs.com/Answer1215/p/14131342.html