private List doQueryPage(String sql, Class className) { int recordCount = doQueryForInt("select count(*) from (" + sql + ") rm_a"); int[] aPage_size_current = (int[]) RmRequestMonitor.getCurrentThreadRequest().getAttribute(ICoreConstants.RM_CURRENT_PAGE); RmPageVo pageVo = new RmPageVo(recordCount, aPage_size_current[0]); pageVo.setCurrentPage(aPage_size_current[1]); RmRequestMonitor.getCurrentThreadRequest().setAttribute(ICoreConstants.RM_PAGE_VO, pageVo); return doQuery( sql, getDefaultRowMapper(className), pageVo.getCurrentPage(), pageVo.getPageSize()); }
/** * 简单查询,分页显示,支持表单回写 * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward simpleQuery( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (RM_YES.equals(request.getParameter(REQUEST_IS_READ_ONLY))) { request.setAttribute(REQUEST_IS_READ_ONLY, request.getParameter(REQUEST_IS_READ_ONLY)); } IRmCodeTypeService service = getService(); String queryCondition = super.getQueryCondition(request); // 从request中获得查询条件 String bs_keyword = IOrgauthConstants.Authorize.RM_CODE_TYPE.bsKeyword(); RmAuthorizeVo authorize = RmAuthorizeCache.getAuthorizeByBs_keyword(bs_keyword); RmPageVo pageVo = RmJspHelper.transctPageVo( request, getService() .getRecordCount( queryCondition, authorize, RmProjectHelper.getRmUserVo(request).getParty_id_all())); String orderStr = RmJspHelper.getOrderStr(request); // 得到排序信息 List<RmCodeTypeVo> beans = service.queryByCondition( queryCondition, orderStr, pageVo.getStartIndex(), pageVo.getPageSize(), authorize, RmProjectHelper.getRmUserVo(request).getParty_id_all()); // 按条件查询全部,带排序 RmJspHelper.saveOrderStr(orderStr, request); // 保存排序信息 request.setAttribute(REQUEST_QUERY_CONDITION, queryCondition); request.setAttribute(REQUEST_BEANS, beans); // 把结果集放入request request.setAttribute( REQUEST_WRITE_BACK_FORM_VALUES, RmVoHelper.getMapFromRequest((HttpServletRequest) request)); // 回写表单 return mapping.findForward(FORWARD_LIST_PAGE); }