您好,欢迎访问三七文档
基于Jmesa,从数据库表Person中查询出记录,能够实现分页、排序、导出功能。同时结合Jquery,利用ajax实现对数据的删除操作。引用Jmesa:2.3Struts2:2.0.11Spring:2.5Hibernate:3.2.5Jquery:jquery1.2.1.pack,jquery.bgiframe.packTomcat:5.5Mysql:5.0数据库、页面、JVM编码统一为GBK数据库表结构:Sql代码1.CREATETABLE`person`(2.`id`int(10)unsignedNOTNULLauto_increment,3.`firstName`varchar(45)NOTNULL,4.`lastName`varchar(45)NOTNULL,5.PRIMARYKEY(`id`)6.)ENGINE=MyISAMAUTO_INCREMENT=76DEFAULTCHARSET=latin1;7.CREATETABLE`person`(8.`id`int(10)unsignedNOTNULLauto_increment,9.`firstName`varchar(45)NOTNULL,10.`lastName`varchar(45)NOTNULL,11.PRIMARYKEY(`id`)12.)ENGINE=MyISAMAUTO_INCREMENT=76DEFAULTCHARSET=latin1;页面list.jsp:Html代码1.%@taglibprefix=“s”uri=“/struts-tags”%2.%@pagelanguage=“java”errorPage=“/error.jsp”pageEncoding=“GBK”contentType=“text/html;charset=GBK”%3.html4.head5.linkrel=“stylesheet”type=“text/css”href=“%=request.getContextPath()%/css/web.css”/link6.linkrel=“stylesheet”type=“text/css”href=“%=request.getContextPath()%/css/jmesa.css”/link7.!–8.对jmesa.js脚本的应用必须放到头部,而不能放到尾部9.–10.scripttype=“text/javascript”src=“%=request.getContextPath()%/js/jmesa.js”/script11./head12.body13.pJmesa表单组件使用演示样例/p14.15.formname=“personForm”action=“%=request.getContextPath()%/list.action”method=“post”16.divid=“persons”17.%18.out.println(request.getAttribute(“myhtml”));19.%20./div21./form22.23.scripttype=“text/javascript”24.functiononInvokeAction(id){25.setExportToLimit(id,”);26.createHiddenInputFieldsForLimitAndSubmit(id);27.}28.functiononInvokeExportAction(id){29.varparameterString=createParameterStringForLimit(id);30.location.href=‘%=request.getContextPath()%/list.action?’+parameterString;31.}32.33.functiondelUser(tableId,rowId){34.varparameterString=createParameterStringForLimit(tableId);35.$.get(“%=request.getContextPath()%/ajax.action?id=”+rowId+“&”+parameterString,function(data){36.$(“#persons”).html(data)37.});38.39.}40./script41.scripttype=“text/javascript”src=“%=request.getContextPath()%/js/SPANclass=hilite2jquery/SPAN-1.2.1.pack.js”/script42.scripttype=“text/javascript”src=“%=request.getContextPath()%/js/SPANclass=hilite2jquery/SPAN.bgiframe.pack.js”/script43.44./body45./html46.%@taglibprefix=“s”uri=“/struts-tags”%47.%@pagelanguage=“java”errorPage=“/error.jsp”pageEncoding=“GBK”contentType=“text/html;charset=GBK”%48.html49.head50.linkrel=“stylesheet”type=“text/css”href=“%=request.getContextPath()%/css/web.css”/link51.linkrel=“stylesheet”type=“text/css”href=“%=request.getContextPath()%/css/jmesa.css”/link52.!–53.对jmesa.js脚本的应用必须放到头部,而不能放到尾部54.–55.scripttype=“text/javascript”src=“%=request.getContextPath()%/js/jmesa.js”/script56./head57.body58.pJmesa表单组件使用演示样例/p59.60.formname=“personForm”action=“%=request.getContextPath()%/list.action”method=“post”61.divid=“persons”62.%63.out.println(request.getAttribute(“myhtml”));64.%65./div66./form67.68.scripttype=“text/javascript”69.functiononInvokeAction(id){70.setExportToLimit(id,”);71.createHiddenInputFieldsForLimitAndSubmit(id);72.}73.functiononInvokeExportAction(id){74.varparameterString=createParameterStringForLimit(id);75.location.href=‘%=request.getContextPath()%/list.action?’+parameterString;76.}77.78.functiondelUser(tableId,rowId){79.varparameterString=createParameterStringForLimit(tableId);80.$.get(“%=request.getContextPath()%/ajax.action?id=”+rowId+“&”+parameterString,function(data){81.$(“#persons”).html(data)82.});83.84.}85./script86.scripttype=“text/javascript”src=“%=request.getContextPath()%/js/jquery-1.2.1.pack.js”/script87.scripttype=“text/javascript”src=“%=request.getContextPath()%/js/jquery.bgiframe.pack.js”/script88.89./body90./htmlAction代码:Java代码1.packagecom.mobilesoft.esales.webapp.action;2.3.importjava.io.IOException;4.importjava.lang.reflect.InvocationTargetException;5.importjava.util.ArrayList;6.importjava.util.List;7.8.importjavax.servlet.http.HttpServletRequest;9.10.importjxl.demo.CSV;11.12.importorg.apache.commons.beanutils.BeanUtils;13.importorg.jmesa.facade.TableFacade;14.importorg.jmesa.facade.TableFacadeImpl;15.importorg.jmesa.limit.Limit;16.17.importcom.mobilesoft.esales.dao.hibernate.Person;18.importcom.mobilesoft.esales.service.PersonService;19.importcom.octo.captcha.service.CaptchaServiceException;20.importcom.opensymphony.xwork2.Action;21.importstaticorg.jmesa.limit.ExportType.CSV;22.importstaticorg.jmesa.limit.ExportType.JEXCEL;23.importstaticorg.jmesa.limit.ExportType.PDF;24.importorg.jmesa.core.filter.DateFilterMatcher;25.importorg.jmesa.core.filter.MatcherKey;26.importorg.jmesa.facade.TableFacade;27.importorg.jmesa.facade.TableFacadeImpl;28.importorg.jmesa.limit.Limit;29.importorg.jmesa.util.ItemUtils;30.importorg.jmesa.view.component.Column;31.importorg.jmesa.view.component.Row;32.importorg.jmesa.view.component.Table;33.importorg.jmesa.view.editor.BasicCellEditor;34.importorg.jmesa.view.editor.CellEditor;35.importorg.jmesa.view.editor.DateCellEditor;36.importorg.jmesa.view.html.HtmlBuil
本文标题:基于struts2+spring+hibernate+jquery的jmesa分页实现样例
链接地址:https://www.777doc.com/doc-5948676 .html