Spring MVC combines spring data JPA to realize conditional query and paging
This example shares the specific code of Android Jiugongge picture display for your reference. The specific contents are as follows
Recommended Video: Shangsi Valley spring data JPA video tutorial. You can learn it as soon as you learn it. Baidu has it once.
Background code: implemented by inheriting the pagingandsortingrepository interface of spring data JPA on the Dao layer (the implementation method is mainly in the sbglserviceimpl. Java class)
Front desk performance: expressed with kkpaper
Effect achieved:
1. Entity class
2. JSP page, look at the bottom paging component (kkpaper)
The resultmap collection is all the data information obtained after the last query and paging in the controller below. Resultmap Resultlist: resultlist is the attribute of map set, which contains < key, value > data
3. Controller (see the processing method below the red font)
3.2、SbglUtil. java
Encapsulate the query parameters passed from the foreground and the paging parameters passed from the foreground into the map set serargs
3.3、SbglService. java
3.4、SbglServiceImpl. Java (query according to the query parameters passed from the foreground, and put the obtained result data into the page objpage parameter)
3.4. 1、PageUtils. Java (paging data tool class)
4, DAO (SbglDao.java), right, it only needs to inherit the PagingAndSortingRepository interface of Spring Data JPA, and its findAll () method is invoked in Controller.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.