分页查询过程中遇到的问题总结
在实现分页查询的过程中,页面没有从数据库中查询到任何内容
此时对应的动态查询逻辑是:
ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("title", GenericPropertyMatchers.contains());
withMatcher =withMatcher.withIgnorePaths("articleType","clickNum","praiseCount","sort","commentNum");
经过不断尝试,当将忽略字段改为下面内容时:(也就是将articleId字段加到了忽略匹配字段中)
ExampleMatcher withMatcher = ExampleMatcher.matching().withMatcher("title", GenericPropertyMatchers.contains());
withMatcher =withMatcher.withIgnorePaths("articleId","articleType","clickNum","praiseCount","sort","commentNum");
然后页面就正常了
总结发现,当在withIgnortPaths()字段中加入所有类型为int的列属性时,分页查询功能作用正常。
关于分页查询的补充:
分页查询中,默认匹配器的字符串采用精准查询,忽略大小写,通过GenericPropertyMatchers.contains()将匹配器改为模糊匹配,