问答详情
源自:8-3 整合MyBatis - 使用pagehelper实现分页

实施分页后,从第二页后数据全部消失

service层
@Override
@Transactional
public PageInfo<FirewallCode> getFirewallsByConds(FirewallCond firewallCond, int page, int limit) {
    PageHelper.startPage(page,limit); //写在上面 可分页
    List<FirewallCode> firewalls = firewallDao.getFirewallsByConds(firewallCond.getEnvironment(),firewallCond.getSourceServer(),
            firewallCond.getSourceIp(),firewallCond.getDestinationServers(),firewallCond.getDestinationIp(),firewallCond.getKind(),
            firewallCond.getPort());
   // PageHelper.startPage(page,limit);  //这种情况 不分页
    PageInfo<FirewallCode> pageInfo = new PageInfo<>(firewalls);
    return pageInfo;

control层

@RequestMapping(value = "/search")
public String search(
        String environment,
        String sourceServer,
        String sourceIp,
        String destinationServers,
        String destinationIp,
        String kind,
        String port,
        Model model,
        @RequestParam(value = "page",required = false, defaultValue = "1") int page,
        @RequestParam(name = "limit", required = false,  defaultValue = "10") int limit

) {
    FirewallCond firewallCond = new FirewallCond();
   firewallCond.setDestinationIp(destinationIp);
   firewallCond.setDestinationServers(destinationServers);
   firewallCond.setEnvironment(environment);
   firewallCond.setKind(kind);
   firewallCond.setPort(port);
    firewallCond.setSourceIp(sourceIp);
    firewallCond.setSourceServer(sourceServer);
    PageInfo<FirewallCode> firewalls= firewallService.getFirewallsByConds(firewallCond,page,limit);
    model.addAttribute("firewalls",firewalls);
    return "admin/firewall_list";
}


提问者:慕莱坞3214507 2020-11-19 10:53

个回答

  • jfhdibrbfjd
    2021-07-08 00:04:46

    好好看看代码有什么问题。