如题!
望大虾解答!
以下是我的代码:
- Java code
@SuppressWarnings("unchecked") public PageModel<Book> findByTypeName(int pageNo, int pageSize, String typename) { String sql = "select * from (" + " select *,row_number() over(order by pubtime) rownum " + " from new_book where typename = ?) temp " + " where rownum between ? and ?"; List<Book> all = new ArrayList<Book>(); PageModel<Book> pageModel = new PageModel<Book>(); int counts = this.getTotalRecords("select count(1) from new_book where typename = " + typename); if(counts <=0) { return null; } else { pageModel.setTotalRecords(counts); pageModel.setTotalPages(); pageModel.setPageNo(pageNo); int start = pageModel.getPageSize()*(pageModel.getPageNo()-1) + 1; int end = pageModel.getPageSize()*pageModel.getPageNo(); all = getJdbcTemplate().queryForList(sql, new Object[] {typename ,start, end});System.out.println(sql + " " + start + " " + end + " " + typename + " " + counts); System.out.println("List 大小:" + all.size()); pageModel.setList(all); return pageModel; } }
------解决方案--------------------
查询本来就没结果败
------解决方案--------------------
你确定吗?看下条件有没有放错位置吧
------解决方案--------------------
那你看看参数传的都对吗?getJdbcTemplate() 是不是空的