I'm developing a web application using MVC architectural pattern.
I have to create a PaginationFactory
class that I can dynamically use for the various section of the application. I've several examples on google and StackOverflow... But mostly old stuff like this question .
Any ideas on how implement this function with using something more modern? Maybe with JQuery
and Ajax
as support?
I suggest for you to use Spring Data Jpa, it's already have implemented pagination.
Your repository will look like this:
public interface MedicamentRepository extends JpaRepository<Medicament, Integer> {}
You can extend, as example, PagingAndSortingRepository interface, if you don't need some of methods that JpaRepository provides.
public class SomeClass{
@Autowired
public MedicamentRepository medicamentRepo;
public void someMethod(){
//in spring data jpa, page count starts from 0;
PageRequest pageRequest = new PageRequest(pageNumber,
pageSize); //also have sorting
org.springframework.data.domain.Page<Medicament> page = medicamentRepo.findAll(pageRequest);
}
}
you can read more here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.