/** * 转换为Map对象 * * @param dayList * @param totalCountDay * @param pageIndex * @return */ public Map getPagination2(List stList, int totalCount, String pageIndex) { List mapList = new ArrayList(); Map mapData = new LinkedHashMap(); for (int i = 0; i < stList.size(); i++) { StudentInfo s = (StudentInfo) stList.get(i); Map cellMap = new LinkedHashMap(); cellMap.put("id", s.getStu_id()); cellMap.put( "cell", new Object[] { s.getStu_id(), s.getStu_code(), s.getStu_name(), s.getStu_school(), s.getStu_class() }); mapList.add(cellMap); } // if (null == oilManage) { // oilManage = new OilManage(); // } mapData.put("page", pageIndex); // 从前台获取当前第page页 mapData.put("total", totalCount); // 从数据库获取总记录数 mapData.put("rows", mapList); return mapData; }
/** 展示详细 */ public String stShow() { final String vehTitle = "学生选择列表"; int totalCount = 0; UserInfo user = getCurrentUser(); HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST); // 每页显示条数 String rpNum = request.getParameter("rp"); // 当前页码 String pageIndex = request.getParameter("page"); String sortName = request.getParameter("sortname"); String sortOrder = request.getParameter("sortorder"); try { if (info == null) { info = new StudentInfo(); } info.setOrganization_id(user.getOrganizationID()); info.setEnterprise_id(user.getEntiID()); info.setSortname(sortName); info.setSortorder(sortOrder); if (info.getStu_id() == null || "none".equals(info.getStu_id()) || "".equals(info.getStu_id())) { info.setStu_id("-1"); } totalCount = service.getCount("RidingPlan.getCountSTShow", info); studentList = (List<StudentInfo>) service.getObjectsByPage( "RidingPlan.getStudentShow", info, (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(rpNum), Integer.parseInt(rpNum)); this.map = getPagination2(studentList, totalCount, pageIndex); } catch (BusinessException e) { addActionError(getText(e.getMessage())); log.error(vehTitle, e); return ERROR; } return SUCCESS; }