问题描述
- ibtais中user.xml中的.page.end与page.start怎么赋值的?
-
user.xml
只有这两个page对象调用<![CDATA[
select * from (select rownum rn,tu.party_id,tu.user_account,tu.password,tu.valid,tu.creater_id,tu.create_time,
tu.password_status,tu.terminal_use_flag,tu.desktop_use_flag,tu.valid_desk,tu.flag,tu.work_code,tu.team_code,tu.transfer_type,tu.card_transfer_type,
tp.party_name,tor.org_name,tor.org_code,tor.manager_org_code
]]><![CDATA[
and rownum<=# page.end #
) A WHERE rn> ** #page.start# **]]>
Pagination分页控制类
package bj.n22.base.common;/**
- 作用:分页的控制
- @author wenc
- */
public class Pagination {/**
- 总记录数
*/
private int rowCount;
/**
- 当前页
/
private int currentPage = 1;
/* - 下一页
/
private int nextPage;
/* - 上一页
- /
private int priPage;
/* - 最后一页
*/
private int lastPage;
/**
- 总页数
*/
private int pageCount;
/**
- 每页的显示数量
- */
private int paginalNum;
/**
- 构造函数 初始化每页显示的条数
*/
public Pagination() {
paginalNum = 10;
}
/**
- @return Returns the pageCount.
*/
public int getPageCount() {
return pageCount;
}
/**
- @param pageCount
- The pageCount to set.
*/
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
/**
- @return Returns the currentPage.
*/
public int getCurrentPage() {
return currentPage;
}
/**
- @param currentPage
*/
public void setCurrentPage(int currentPage) {
if (currentPage < 1)
return;
this.currentPage = currentPage;
}
/**
- @return Returns the paginalNum.
*/
public int getPaginalNum() {
return paginalNum;
}
/**
- @param paginalNum
- The paginalNum to set.
/
public void setPaginalNum(int paginalNum) {
if (paginalNum < 1)
return;
this.paginalNum = paginalNum;
}
/*- @return Returns the priPage.
*/
public int getPriPage() {
if (currentPage > 1) {
priPage = currentPage - 1;
} else {
priPage = currentPage;
}
return priPage;
}
/**
- @return
*/
public int getLastPage() {
lastPage = rowCount % paginalNum == 0 ? rowCount / paginalNum
: rowCount / paginalNum + 1;
return lastPage;
}
/**
- @return
/
public int getNextPage() {
getLastPage();
if (currentPage < lastPage) {
nextPage = currentPage + 1;
} else {
nextPage = currentPage;
}
return nextPage;
}
/* - @param rowCout
- The rowCout to set.
*/
public void setRowCount(int rowCount) {
if (rowCount < 0)
return;
this.rowCount = rowCount;
pageCount = rowCount / paginalNum;
if (rowCount % paginalNum !=0){
pageCount =pageCount + 1;
}
}
/**
- @return the rowCount
*/
public int getRowCount() {
return rowCount;
}
/**用于 oracle查询时的起始记录数
- @return
*/
public int getStart(){
return (this.getCurrentPage() -1) * this.getPaginalNum();
}
/**用于 oracle查询时的截止记录数
- @return
*/
public int getEnd(){
return this.getCurrentPage() * this.getPaginalNum();
}
/** 设置当前页,从客户端获取的字符串时方便调用
- @param currentPage
*/
public void setCurrentPage(String currentPage){
int curPage=1;
if (currentPage !=null && !"".equals(currentPage.trim())){
curPage =Integer.parseInt(currentPage);
}
this.setCurrentPage(curPage);
}
- 总记录数
}
Action类
public String searchUsers() throws UnsupportedEncodingException {Pagination page = new Pagination();
String currentPage = request.getParameter("currentPage");
page.setCurrentPage(currentPage);
//获得登陆用户角色
UserSession user = SessionManager.getLoginUser(request);
//获得登陆用户所在机构ID
String userOrgCode = user.getOrgCode();
if( !userOrgCode.equals(SystemConstant.SUPER_ORG_CODE)){
if(model.getOrgCode()==null && model.getOrgName()==null ){
model.setOrgCode(userOrgCode);
model.setOrgName(user.getOrgName());
}
}
//获得用户所属渠道
model.setChannelCode(user.getChannelCode());
//如果从启动移动展业跳转而来的,要对中文参数进行转码
String stemFrom = request.getParameter("stemFrom");
if(StringUtils.isNotEmpty(stemFrom)){
model.setPartyName(new String(model.getPartyName().getBytes("ISO-8859-1"), "UTF-8"));
model.setOrgName(new String(model.getOrgName().getBytes("ISO-8859-1"), "UTF-8"));
}
QueryResult result = usersService.searchUsers(model, page);
page.setRowCount(result.getCount());
if(userOrgCode.equals(SystemConstant.SUPER_ORG_CODE)){
request.setAttribute("userOrgCode", null);
request.setAttribute("userOrgName", null);
}else{
request.setAttribute("userOrgCode", userOrgCode);
request.setAttribute("userOrgName", user.getOrgName());
}model.setUserAccount(account); request.setAttribute("listStr", listStr); request.setAttribute("list", result.getList()); request.setAttribute("page", page); return this.SUCCESS; }
UsersServiceImpl类
public QueryResult searchUsers(Users users, Pagination page) {
users.setPartyName(users.getPartyName()==null?"":users.getPartyName().trim());
users.setUserAccount(users.getUserAccount()==null?"":users.getUserAccount().trim());
return usersDao.searchUsers(users, page);
}
UsersDaoImpl类
public QueryResult searchUsers(Users users,Pagination page) {
return baseDao.search("nci-system-users.searchUsers",users,page) ;
}BaseDaoImpl基类
public QueryResult search(String statementName,Object model,Pagination page) {
Map map=new HashMap();
map.put("page",page);
map.put("model", model);
List list=queryForList(statementName, map);
int count=queryForInt(statementName + "_count", map);
QueryResult result=new QueryResult();
result.setCount(count);
result.setList(list);
return result ;
}