+ -
当前位置:首页 → 问答吧 → SSH框架里实现带条件的分页查询?~急。

SSH框架里实现带条件的分页查询?~急。

时间:2011-12-02

来源:互联网

在SSH框架中,实现 带条件的分页查询 ,不使用ExtJs和Jquery,困扰了一下午了。求解释啊。最好有源码实例。

作者: lsbggg   发布时间: 2011-12-02

public class Page<T> {
  // -- 公共变量 --//
  public static final String ASC = "asc";
  public static final String DESC = "desc";

  // -- 分页参数 --//
  protected int pageNo = 1; //第几页
  protected int pageSize = 1; //每页显示的数量
  protected String orderBy = null;
  protected String order = null;
  protected boolean autoCount = true;

  // -- 返回结果 --//
  protected List<T> result = Lists.newArrayList(); //查询的结果
  protected long totalCount = -1;//查询数据的总数

  // -- 构造函数 --//
  public Page() {
  }
}
其他代码就不写了,
其实就是 你先取出所有的数据得到总数,
然后根据你的页面和每页显示的数量判断出 要显示的数据是冲多少开始查询,查多少数据。这个hibernate自带的方法
setFirstResult(int i)重第几个开始查询
setMaxResults(int i)查几个

大概就是这样啦,具体的话 自己慢慢的查资料写把,
有写东西自己写了 会明白很多东西

作者: LS1firesoar   发布时间: 2011-12-02

热门下载

更多