日期:2014-05-17  浏览次数:20749 次

求助:jsp页面分页的问题
for(int i=0;i<list.size();i++){
user = list.get(i);
String provin = dao.byPid(user.getLife_province());
String city = dao.byId(user.getLife_city());
System.out.println(city);
%>
<table>
<div>
<ul>
<li>
<p class="img"><img src=<%=user.getFace() %> alt="" /></p>
<p class="name"><a href="javascript:"><%=user.getUsername() %></a></p>
<p class="adr"><span><%=user.getBirthday() %></span><span>财务人员</span><span><%=provin %>省<%=city %>市</span></p>
<p class="message"><input name="button" type="button" class="qqmes" /><input name="button" type="button" class="leamess" /></p>
</li>
<%} %>

------解决方案--------------------
探讨
引用:

你这样想要实现分页太慢了。因为你是一次取全部数据。
select * from table limit 1,10;

看到这个语句没,这就是分页的sql

这个我也想过 但是sql Server不支持这样查询

------解决方案--------------------
Java code



ListAction.java



package com.sy.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.sy.dao.AdminDao;
import com.sy.dao.NewsDao;
import com.sy.dao.impl.AdminDaoImpl;
import com.sy.dao.impl.NewsDaoImpl;
import com.sy.vo.Admin;
import com.sy.vo.News;

public class ListAction extends ActionSupport {

    private static final long serialVersionUID = 1L;
        int i=1;//中间变量
    private int k;//储存最大页面数
    private int pageNow=1; //页码数,初始为1
    private int pageSize = 5 ; //页面行数 
    private int intRowCount;//总行数
    private int intPageCount;//总页数
    private Admin admin;
    private List<Admin> Adminss;
    private News news;
    @SuppressWarnings("unchecked")
    private List<News> Newss;
    
    private int id;
    private int aid;

    public News getNews() {
        return news;
    }

    public void setNews(News news) {
        this.news = news;
    }

    @SuppressWarnings("unchecked")
    public List<News> getNewss() {
        return Newss;
    }
    public void setNewss(List<News> newss) {
        Newss = newss;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    public Admin getAdmin() {
        return admin;
    }

    public void setAdmin(Admin admin) {
        this.admin = admin;
    }

    public List<Admin> getAdminss() {
        return Adminss;
    }

    public void setAdminss(List<Admin> adminss) {
        Adminss = adminss;
    }
    public int getAid() {
        return aid;
    }

    public void setAid(int aid) {
        this.aid = aid;
    }

    public int getPageNow() {
        return pageNow;
    }

    public void setPageNow(int pageNow) {
        this.pageNow = pageNow;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getIntRowCount() {
        return intRowCount;
    }

    public void setIntRowCount(int intRowCount) {
        this.intRowCount = intRowCount;
    }

    public int getIntPageCount() {
        return intPageCount;
    }

    public void setIntPageCount(int intPageCount) {
        this.intPageCount = intPageCount;
    }
    public int getK() {
        return k;
    }

    public void setK(int k) {
        this.k = k;
    }
@SuppressWarnings("unchecked")
    @Override
//显示新闻列表
    public String execute() throws Exception {

        NewsDao npage=new NewsDaoImpl();
        intRowCount=npage.count();