This article is mainly used for individual study and review. Welcome to guide, discuss
1, add maven dependency
<dependency>
<groupId>com.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
<version>1.2.17</version>
</dependency>
2. Add a paging plugin to the configuration file
<plugin interceptor= "Com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor" >
<property name= "Dialectclass" value= "Com.github.miemiedev.mybatis.paginator.dialect.MySQLDialect"/>
</plugin>
adding interceptors to the 3,SPRINGMVC configuration file(Purpose: To remove the paginator containing pagelist in ServletRequest and Modelandview and to establish a property named the +paginator suffix of the original property name)
<mvc:interceptor>
<mvc:mapping path= "/**"/>
<bean
class= "Com.github.miemiedev.mybatis.paginator.springmvc.PageListAttrHandlerInterceptor"/>
</mvc:interceptor>
4, the code implementation:
Controller:list<a> Lista=getabypage (classa,new pagebounds (page, limit, order.formstring ("A.asc,b.desc")); /"," Split to sort multiple columns, but where A and B are attributes or fields?
ServiceImpl:Adao.getAByPage (Classa,pagebounds);
Interfacedao: @Select ("* * *") | @SelectProvider
List<a> getabypage (classa,pagebounds);
5, Page call: (Collection +paginator. Properties)
Prev: ${listapaginator.prepage}
Current page: ${listapaginator.page}
Next: ${listapaginator.nextpage}
Total Pages: ${listapaginator.totalpages}
Total number of bars: ${listapaginator.totalcount}
Reference article: http://blog.csdn.net/z69183787/article/details/48947623 (I do not know whether the original)
Individual issues to be resolved:
1,step4 A, B is a field name or a class property?
2, can you integrate with Elasticsearch query? Because Elasticsearchtemplate.queryforlist (Searchquery.build (), classa.class); This method series overload does not seem to set the PageBounds parameter, or somewhere else to pass in it?
MyBatis Paging +springmvc+jsp+maven Use steps