算出这条记录所在的rowNum,rowNum是连续的,再根据rowNum算出这条记录所在的页码。
public int getPageNoByBackId(int noteId,int backId,int pageSize) { StringBuilder sql = new StringBuilder(); sql.append(" select num from ( \n"); sql.append("select ROW_NUMBER() over(order by backId) as num,backId \n"); sql.append("from forum..f_topic_reply where noteId=? \n"); sql.append(") a where a.backId =? \n"); log.debug(sql.toString()); int rowNum = 0; DB db = null; try { db = getGkDB(); rowNum = db.queryForInt(sql.toString(), new Object[] {noteId,backId}); } catch (Exception e) { log.error(e); }finally{ if(db!=null)db.close(); } int pageNum = 0; if(rowNum>0){ if(rowNum%pageSize==0){ pageNum=rowNum/pageSize; }else{ pageNum=rowNum/pageSize+1; } } return pageNum; }
如果一个链接里有锚点,跳转的时候用window.location打开不起作用,但在document.location中打开是可以的
时间: 2024-10-03 22:29:01