本文主要是介绍webwork和ibatis分页,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
首先action上的属性
public class MyObjExamAction extends ActionSupport implements ModelDriven {MyObjExamModel exam = new MyObjExamModel();private List list;private String cp;private int curPage;private int totPage;private int totSize;String flag = "";
list方法的设置
public String query_examAndTest() throws Exception{
……
…… MyPage mp = new MyPage();totSize = mp.getTotSize(exam, "queryTestExamtTotal");int index = 0;//我加的**cp = req.getParameter("cp");if (cp == null || cp.trim().length()==0 || cp.equals("0")) {index = 1;curPage = index;cp = curPage + "";} elseindex = (new Integer(cp)).intValue();SqlMapClient map = null;try {map = SqlMap.getSqlMapInstance();//exam.setCurPage(index);int start = row_count * (index - 1) + 1;int end = start + row_count - 1;exam.setStart(start);exam.setEnd(end); exam.setCurPage(index);req.setAttribute("curPage", String.valueOf(index));curPage = index;//得到所有考试list = map.queryForList("queryTestExam", exam); exam.setTotSize(totSize); exam.setTotPage(mp.getTotPage(totSize,row_count));String obj_name="";String object_id=exam_wh_id+"";//得到 培训班名称 或 课程名称if("T".equals(exam_wh_id_type)||"X".equals(exam_wh_id_type)){//faxc 加上系列培训("X")的判断obj_name = (String) map.queryForObject("select_object_tbc_name", object_id);}else if("C".equals(exam_wh_id_type)){obj_name = (String) map.queryForObject("select_object_icr_name", object_id);}req.setAttribute("list", list);req.setAttribute("obj_name", obj_name);if(req.getParameter("icr_id")!=null && req.getParameter("icr_id").length()>0)exam.setIcr_id(req.getParameter("icr_id"));if(req.getParameter("tbc_id")!=null && req.getParameter("tbc_id").length()>0)exam.setTbc_id(req.getParameter("tbc_id"));return "success"; } catch (Exception ex) {ex.printStackTrace();return ERROR;}}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
另外一个流程的分页
action上的属性
public class Training_bag_classAction extends ActionSupport implementsModelDriven {private Speciality spe=new Speciality();private Trainproject tp=new Trainproject();Year_Model ym=new Year_Model();private File userFile;private Question qu=new Question();private int curPage1;private int totPage1;private int totSize1;private String cp1;private int curPage2;private int totPage2;private int totSize2;private String cp2;private List list;private HashMap hm=new HashMap();private List t_cert_list;private List cert_list;private List tbc_id_list;private List tbc_name_list;private Training_bag_class tbc = new Training_bag_class();private Post post = new Post();private User user=new User();private Cert cert=new Cert();private Teacher_model t=new Teacher_model();private String cp;private int curPage;private int totPage;private int totSize;String flag = "";private String dateError;private int Id;private int ugId;private int sit_id;private String pageNum;private String pageCount;CommonDao cd = new CommonDao();
list方法
public String select_training_bag_class_user() throws Exception {……
……//分页**************MyPage mp = new MyPage();int index = 0;int row_count=user.getDefaultRow_count();if (req.getParameter("row_count") != null && req.getParameter("row_count") != "") {row_count = Integer.parseInt(req.getParameter("row_count"));}req.setAttribute("row_count", row_count+"");cp = req.getParameter("cp");if (cp == null || cp.equals("") || cp.equals("0")) {index = 1;curPage = index;cp = curPage + "";} elseindex = (new Integer(cp)).intValue();if(c_id==1){//totSize = mp.getTotSize(user, "select_req_training_bag_class_user_totalcount");totSize = mp.getTotSize(user, "select_req_training_bag_class_user_totalcount2");totPage = mp.getTotPage(totSize,row_count);req.setAttribute("totPage", totPage+"");}else if(c_id==2){//totSize = mp.getTotSize(user, "select_open_training_bag_class_user_totalcount");totSize = mp.getTotSize(user, "select_open_training_bag_class_user_totalcount2");totPage = mp.getTotPage(totSize,row_count);req.setAttribute("totPage", totPage+"");}else if(c_id==3){totSize = mp.getTotSize(user, "select_allow_training_bag_class_user_totalcount2");totPage = mp.getTotPage(totSize,row_count);req.setAttribute("totPage", totPage+"");}flag = req.getParameter("flag");if (flag != null) {if (flag.equals("2"))index++;else if (flag.equals("1"))index--;else if (flag.equals("0"))index = 1;else if (flag.equals("3"))index = totPage;if (index <= 0)index = 1;else if (index > totPage)index = totPage;} elseindex = 1;int start = row_count * (index - 1) + 1;int end = start + row_count - 1;user.setStart(start);user.setEnd(end);tbc.setCurPage(index);tbc.setTotSize(totSize);//******************************************try {map = SqlMap.getSqlMapInstance();String isyn = "";try{isyn = (String)map.queryForObject("get_tbc_year_plan_isyn",String.valueOf(id));}catch(Exception e){isyn = "";}req.setAttribute("isyn", isyn);if(c_id==1){//list = map.queryForList("select_req_training_bag_class_user", user);list = map.queryForList("select_req_training_bag_class_user2", user);}else if(c_id==2){//list = map.queryForList("select_open_training_bag_class_user", user);list = map.queryForList("select_open_training_bag_class_user2", user);String is_learn_all =map.queryForObject("select_tbc_is_learn_all",user)+"";req.setAttribute("is_learn_all", is_learn_all);}else if(c_id==3){list = map.queryForList("select_allow_training_bag_class_user2", user);}req.setAttribute("list", list);
// req.setAttribute("msgsuccess", "success");req.setAttribute("result", req.getParameter("result"));return SUCCESS;} catch (Exception ex) {ex.printStackTrace();req.setAttribute("msgsuccess", "error");return ERROR;}}
这篇关于webwork和ibatis分页的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!