SSH框架里实现带条件的分页查询?~急。 在SSH框架中,实现 带条件的分页查询 ,不使用ExtJs和Jquery,困扰了一下午了。求解释啊。最好有源码实例。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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)查几个大概就是这样啦,具体的话 自己慢慢的查资料写把,有写东西自己写了 会明白很多东西 不是有方法吗?String sql="from RPMS_user user where user.userName=? and user.userPass=?"; Query query=sessionFactory.getCurrentSession().createQuery(sql); query.setParameter(0, user.getUserName()); query.setParameter(1, user.getUserPass()); //还要分页的话 query.setMaxResults(5); query.setFirstResult((pageNow-1)*5); jsp文件上传 关于js向action传参(中文)乱码问题 struts2遍历问题 菜鸟的开始 关于文件上传目录的问题 帮我看看,jsp代码为什么有错误! 请教最简单的下载方法,我只需下载一个word文档给客户,是不是可以把这个文挡放到服务器的某目录下,然后用一个什么语句指定给文件路径, 会用xdoclet+ ant产生配置描饰符的朋友请 帮下忙 怎样用jsp 来判断checkbox是否被选中 @Autowired注解的2种方式 jsp页面判断跳转 java jsp点击次数和回复数量进行统计。这个点击次数和回复数怎么实现
// -- 公共变量 --//
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)查几个大概就是这样啦,具体的话 自己慢慢的查资料写把,
有写东西自己写了 会明白很多东西
Query query=sessionFactory.getCurrentSession().createQuery(sql);
query.setParameter(0, user.getUserName());
query.setParameter(1, user.getUserPass());
//还要分页的话
query.setMaxResults(5);
query.setFirstResult((pageNow-1)*5);