前言:分页功能在javaweb项目中经常用到,以常用的持久层框架mybatis为例,它没有提供原生的物理分页功能相关接口,但是mybaits提供了相应的插件功能让我们去做一些相应的扩展。这里我们选择mysql作为数据库。一般我们会直接使用mybatis-helper、mybatis-plus等第三方插件。它们都提供分页功能。我们如何做这些类库?实现:首先我们说到mysql中的分页,就会想到limit关键字;那么在前台使用分页的时候,需要有总页数。分页+条目总数这是一个简单的demo.cache.CacheKey;导入org.apache.ibatis.executor.Executor;导入org.apache.ibatis.mapping.BoundSql;导入org.apache.ibatis.mapping.MappedStatement;导入org.apache.ibatis.mapping.ParameterMapping;导入org.apache.ibatis.plugin.Interceptor;导入org.apache.ibatis.plugin.Intercepts;导入org.apache.ibatis.plugin.Invocation;导入org.apache.ibatis.plugin.Signature;导入org.apache.ibatis.session.ResultHandler;导入org.apache.ibatis.session.RowBounds;导入org.springframework.jdbc.core.JdbcTemplate;导入org.springframework.stereotype.Component;导入java.lang.reflect.Field;导入java.util.ArrayList;导入java.util.List;导入java.util。stream.Collectors;/***@authoryangrd*@date2021/12/7*/@RequiredArgsConstructor@Component@Intercepts({@Signature(type=Executor.class,method="query",args={MappedStatement.class,Object.class,RowBounds.class,ResultHandler.class,CacheKey.class,BoundSql.class})})publicclassMyTestInterceptorimplementsInterceptor{privatefinalJdbcTemplatejdbcTemplate;@OverridepublicObjectintercept(Invocationinvocation)throwsThrowable{BoundSqlboundSql=(BoundSql)invocation.getArgs()[5];StringtempSql=boundSql.getSql();MapperMethod.ParamMap
