📄 turnpagequerybean.java
字号:
package com.uiwz.db;
import java.sql.SQLException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
public class TurnPageQueryBean extends QueryBean
{
public int curPage = 1;
public int maxPage;
public int maxRow;
public int pageSize = 20;
public String sqlStr;
private HttpServletRequest req;
private HttpSession session;
TurnPageAttributes attr;
private String formName;
private boolean isFirst = true;//是否是第一次进入番页
public TurnPageQueryBean(HttpServletRequest req)
throws SQLException
{
super();
this.req = req;
}
private void init()
{
formName = req.getRequestURI();
session = req.getSession();
try
{
attr = (TurnPageAttributes)session.getAttribute(TurnPageAttributes.APP_TURN_PAGE + formName);
String s = req.getParameter("TFP");
String jumpPage = req.getParameter("jumpPage");
if(jumpPage != null)
{
sqlStr = attr.getStatement();
isFirst = false;
this.curPage = Integer.parseInt(jumpPage);
this.maxRow = attr.getMaxRowNo();
}
else if(attr != null && (s == null || !s.equalsIgnoreCase("true")))
{
sqlStr = attr.getStatement();
isFirst = false;
this.curPage = attr.getCurPageNo();
this.maxRow = attr.getMaxRowNo();
}
}
catch(Exception e){}
}
/*
public void setSessionID(String sessionID)
{
this.sessionID = sessionID ;
}
*/
public void setStatement(String sqlStr)
{
this.sqlStr = sqlStr;
}
public void setPageSize(int pageSize)
{
this.pageSize = pageSize;
}
public void setCurPage(int curPage)
{
this.curPage = curPage;
}
//根据总行数计算总页数
public void countMaxPage()
{
if (this.maxRow % this.pageSize == 0)
{
this.maxPage = this.maxRow / this.pageSize;
}
else
{
this.maxPage = this.maxRow / this.pageSize + 1;
}
}
private void setSessionAttrs()
{
if(attr == null)
attr = new TurnPageAttributes();
attr.setCurPageNo(curPage);
attr.setMaxPageNo(maxPage);
attr.setMaxRowNo(maxRow);
attr.setPageSize(pageSize);
attr.setStatement(sqlStr);
session.setAttribute(TurnPageAttributes.APP_TURN_PAGE + formName, attr);
//session.setAttribute("sessionID",sessionID);
}
public void execute()
throws SQLException
{
init();
setStartRow(pageSize * (curPage - 1) + 1);
setStopRow(pageSize * curPage);
super.setStatement(sqlStr);
super.execute();
if(isFirst)
maxRow = getSumRow();
countMaxPage();
setSessionAttrs();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -