webwork和ibatis分页

2024-02-21 14:48
文章标签 分页 ibatis webwork

本文主要是介绍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分页的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/732144

相关文章

Mysql中深分页的五种常用方法整理

《Mysql中深分页的五种常用方法整理》在数据量非常大的情况下,深分页查询则变得很常见,这篇文章为大家整理了5个常用的方法,文中的示例代码讲解详细,大家可以根据自己的需求进行选择... 目录方案一:延迟关联 (Deferred Join)方案二:有序唯一键分页 (Cursor-based Paginatio

mybatis-plus分页无效问题解决

《mybatis-plus分页无效问题解决》本文主要介绍了mybatis-plus分页无效问题解决,原因是配置分页插件的版本问题,旧版本和新版本的MyBatis-Plus需要不同的分页配置,感兴趣的可... 昨天在做一www.chinasem.cn个新项目使用myBATis-plus分页一直失败,后来经过多方

一文教你使用Python实现本地分页

《一文教你使用Python实现本地分页》这篇文章主要为大家详细介绍了Python如何实现本地分页的算法,主要针对二级数据结构,文中的示例代码简洁易懂,有需要的小伙伴可以了解下... 在项目开发的过程中,遇到分页的第一页就展示大量的数据,导致前端列表加载展示的速度慢,所以需要在本地加入分页处理,把所有数据先放

Redis存储的列表分页和检索的实现方法

《Redis存储的列表分页和检索的实现方法》在Redis中,列表(List)是一种有序的数据结构,通常用于存储一系列元素,由于列表是有序的,可以通过索引来访问元素,因此可以很方便地实现分页和检索功能,... 目录一、Redis 列表的基本操作二、分页实现三、检索实现3.1 方法 1:客户端过滤3.2 方法

oracle分页和mysql分页

mysql 分页 --查前5 数据select * from table_name limit 0,5 select * from table_name limit 5 --limit关键字的用法:LIMIT [offset,] rows--offset指定要返回的第一行的偏移量,rows第二个指定返回行的最大数目。初始行的偏移量是0(不是1)。   oracle 分页 --查前1-9

fastreport打印trichedit分页问题的解决

用fastreport来打印richedit里面的内容。刚开始放一个frxrichview组件到报表上,然后在 var str: TMemoryStream; begin    begin      str:= TMemoryStream.Create;      CurrRichRecord.richedit.Lines.SaveToStream(str);      str.Posit

简单Hbase 分页方案

简单Hbase分页方案 网上大多数分页方案分为从服务端分页或者从客户端分页 服务端分页方式主要利用PageFilter过滤器,首先太复杂,其次针对集群的兼容性不是很好,作者利用服务端分页+客户端分页结合方式给出一种简单易行的中间方案。 1.利用PageFilter过滤器从服务端分页,过滤出所需要的最大条数, 注:作者认为大多数用户不会进行太深的翻页,假设pageSize=5,客户饭100页一共

SpringBoot项目-实现简单的CRUD功能和分页查询

背景 本博文主要是创建了一个新的SpringBoot项目,实现基本的增删改查,分页查询,带条件的分页查询功能。是方便初学者学习后端项目的一个比较清晰明了的实践代码,读者可根据博文,从自己动手创建一个新的SpringBoot项目,到使用PostMan测试基本请求,完完全全实践一遍,写出自己的代码,或者实现自己想要的功能。因为在这个过程中会遇到许多的问题,从JDK的版本选择到跑通SpringBo

Jasperreports+jaspersoft studio学习教程(八)- 报表分页和大量数据内存处理

9.1 设计报表模板 9.1.1 使用Table组件新建模板(步骤参考教程七)如下: 9.1.2 模板自带变量 $V{PAGE_NUMBER} :代表当前页数(可以是页码也可以是页数,通过TextField的计算时间的不同值来设置) $V{PAGE_COUNT} :当前页面中记录的数目 $V{groupname_COUNT} :   代表当前组的记录数 $V{COLUMN_NU

操作系统分页式存储管理

每次输入地址后,计算出页号,若页号越界,则给出错误提示。否则依次调用FIFO和LRU算法,这里值得注意的是,由于我们的FIFO算法先于LRU算法被调用,那么当在处理FIFO算法时,我们暂且不将位视图相应位置做变化,留到处理LRU算法再做处理。 对于FIFO、LRU算法的缺页,我们分两种情况考虑,第一种是模拟栈内还有空间,那么直接将其入栈。第二种是模拟栈内无空间,要发生置换。发生置换时把模拟栈最底