解决地址:https://blog.csdn.net/weixin_44781799/article/details/118369705
项目练手:
架构来自于大佬:https://el-admin.vip/
起因是我自己边学边弄,然后就修改了Mybaitsplus的配置文件
然后我自己就学杂了。我觉得配置文件里面的Bean 分开十分清晰,于是我就把人家源文件里面的内容拆开了。导致上面的问题。
然后我就debug 查询,然后我就发现 Page 里面的total 居然为0,页面显示才怪。
百度了一下其他大佬的,今天是幸运的一天,直接就找到了。
来自于大佬:https://blog.csdn.net/weixin_44781799/article/details/118369705
解决方法:
配置分页拦截器,创建一个名为MybatisPlusConfig.java的配置文件,内容如下:
原来的配置文件:
修改后的配置文件:
@MapperScan(basePackages = {"com.yntovi.**.mapper"})
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); // 注册乐观锁插件
interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); // 分页插件
return interceptor;
}
@Bean
public GlobalConfig globalConfig() {
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setMetaObjectHandler(new MybatisPlusFillHandler());
return globalConfig;
}
}