实施分页后,从第二页后数据全部消失
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"; }