共58条记录 每页显示20条 第1页 / 共3页 第一页 上一页 下一页 最后一页 转到第页
58条数据在一页里全显示出来了,不分页
public ActionForward toListByPage(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String type = request.getParameter("type");
if(type.equals("1")){
request.setAttribute("titleName", "通知公告");
}else if(type.equals("2")){
request.setAttribute("titleName", "政策法规");
}
ConsultForm myForm = (ConsultForm) form;
super.getConsultBiz().getListPa(myForm,type);
request.setAttribute("consultList", super.getConsultBiz().getListByType(type));
return mapping.findForward("listByPage");
}
public void getListPa(ConsultForm myForm,String type) {
String hql="from Consult o where o.type="+type+" order by o.id desc";
super.getCommonDAO().listByQuesPage(hql, myForm.getQuesResult());
}@SuppressWarnings("unchecked")
public void listByQuesPage(String hql, QuestionPageResult quesResult) {
if (null == hql) { return; }
Query query = session.createQuery(hql);
query.setFirstResult(quesResult.getFirstRec());
int a=quesResult.getFirstRec();
query.setMaxResults(quesResult.getPageSize());
int b=quesResult.getPageSize();
List ret = query.list();
quesResult.setList(ret);
String queryString = "";
if (hql.toUpperCase().indexOf("SELECT") != -1) {
int i = query.getQueryString().toUpperCase().indexOf("FROM");
queryString = "Select count(*) " + hql.substring(i, hql.length());
} else {
queryString = "Select count(*) " + hql;
}
// 去掉ORDER BY 的部分
int j = queryString.toUpperCase().lastIndexOf("ORDER");
if (j != -1){
queryString = queryString.substring(0, j);
}
Query cquery = session.createQuery(queryString);
cquery.setCacheable(true);
int recTotal = ((Long) cquery.iterate().next()).intValue();
quesResult.setRecTotal(recTotal);
}
58条数据在一页里全显示出来了,不分页
public ActionForward toListByPage(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String type = request.getParameter("type");
if(type.equals("1")){
request.setAttribute("titleName", "通知公告");
}else if(type.equals("2")){
request.setAttribute("titleName", "政策法规");
}
ConsultForm myForm = (ConsultForm) form;
super.getConsultBiz().getListPa(myForm,type);
request.setAttribute("consultList", super.getConsultBiz().getListByType(type));
return mapping.findForward("listByPage");
}
public void getListPa(ConsultForm myForm,String type) {
String hql="from Consult o where o.type="+type+" order by o.id desc";
super.getCommonDAO().listByQuesPage(hql, myForm.getQuesResult());
}@SuppressWarnings("unchecked")
public void listByQuesPage(String hql, QuestionPageResult quesResult) {
if (null == hql) { return; }
Query query = session.createQuery(hql);
query.setFirstResult(quesResult.getFirstRec());
int a=quesResult.getFirstRec();
query.setMaxResults(quesResult.getPageSize());
int b=quesResult.getPageSize();
List ret = query.list();
quesResult.setList(ret);
String queryString = "";
if (hql.toUpperCase().indexOf("SELECT") != -1) {
int i = query.getQueryString().toUpperCase().indexOf("FROM");
queryString = "Select count(*) " + hql.substring(i, hql.length());
} else {
queryString = "Select count(*) " + hql;
}
// 去掉ORDER BY 的部分
int j = queryString.toUpperCase().lastIndexOf("ORDER");
if (j != -1){
queryString = queryString.substring(0, j);
}
Query cquery = session.createQuery(queryString);
cquery.setCacheable(true);
int recTotal = ((Long) cquery.iterate().next()).intValue();
quesResult.setRecTotal(recTotal);
}
解决方案 »
- 怎么能把dos中输出的内容倒到txt文本中?dos中标记完了也不能复制啊
- 跪求!跪求!跪求!iframe引入页面的带值
- 使用xsocket,为啥INonBlockingConnection的remoteaddress是null?
- RTI DDS运行HelloWorld时出现100个错误,大都是某某软件包不存在和找不到错误
- ATGrid WEB报表打印控件/MIS报表控件
- 有没有解吸XML的代码例子,谢谢。进来说
- 前辈们能不能帮帮我:::J2EE组件都有哪些??????????
- 请教actionservlet填充actionform的实现原理
- 如何在WEBLOGIC8.1中添加WL_HOME??
- ###轻松拿分了!!!--新手入门小问题--用JB7做CMP实体Bean时,自定义的finder方法中的SQL语句怎么写?
- 自学时,发现运行异常!请各位指点指点……
- 在客户还是服务器端?
int a=quesResult.getFirstRec();
query.setMaxResults(quesResult.getPageSize());
int b=quesResult.getPageSize();
一种是看看你的住句话赋值成功没?第二种最好是答应出执行的sql语句就明了了 为什么出来了全部的数据。
int a=quesResult.getFirstRec();
query.setMaxResults(quesResult.getPageSize());检查 quesResult.getFirstRec() 这个方法,这个方法需要算出开始的索引