BootStrap实现邮件列表的分页和模态框添加邮件的功能
废话不多说具体代码如下所示:
packagecom.rc.controller; importjava.io.IOException; importjava.io.PrintWriter; importjava.util.ArrayList; importjava.util.List; importjavax.servlet.ServletException; importjavax.servlet.http.HttpServlet; importjavax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse; importjavax.servlet.http.HttpSession; importnet.sf.json.JSONObject; importcom.rc.dao.R_mailboxDAO; importcom.rc.daoimpl.R_mailboxDAOimpl; importcom.rc.dbutil.Sqltools; importcom.rc.entity.Mailbox; importcom.rc.entity.R_user; importcom.rc.entity.TreeNodes; importcom.rc.util.Page; importcom.rc.util.PageUtil; publicclassMailBoxServletextendsHttpServlet{ /** *ThedoGetmethodoftheservlet.<br> * *Thismethodiscalledwhenaformhasitstagvaluemethodequalstoget. * *@paramrequesttherequestsendbytheclienttotheserver *@paramresponsetheresponsesendbytheservertotheclient *@throwsServletExceptionifanerroroccurred *@throwsIOExceptionifanerroroccurred */ @Override publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ response.setContentType("text/html;charset=utf-8"); Stringaction=request.getParameter("action"); HttpSessionhs=request.getSession(false);//读取登录人员session R_usercuser=(R_user)hs.getAttribute("user"); PrintWriterout=null; R_mailboxDAOmb=newR_mailboxDAOimpl(); booleanb=true; if("page".equals(action)){//查询所有 intpageNumber=0; StringPageNumberstr=request.getParameter("pageNumber");//从页面获取的当前页 intcount=mb.getcount(); if(PageNumberstr==null||"".equals(PageNumberstr)){ pageNumber=1; }else{ pageNumber=Integer.parseInt(PageNumberstr);//否则强转 } List<Page>pages=newArrayList<Page>(); Pagepage=PageUtil.createPage(5,count,pageNumber); pages.add(page); List<Mailbox>mailboxlist=mb.getcostList(page); JSONObjectobj=newJSONObject();//定义一个json对象 obj.put("mailbox",mailboxlist); obj.put("Page",pages); out=response.getWriter(); out.write(obj.toString()); }elseif("delete".equals(action)){//删除操作 Stringmid=request.getParameter("id"); JSONObjectobj=newJSONObject(); b=mb.delete(Integer.parseInt(mid));//用boolean接收 obj.put("biaozhi",b); out=response.getWriter(); out.write(obj.toString()); }elseif("edit".equals(action)){//弹出编辑页面 }elseif("tedit".equals(action)){//提交编辑信息 }elseif("pldelete".equals(action)){//批量删除 JSONObjectobj=newJSONObject(); Stringdeleteidlist=request.getParameter("deleteidlist"); String[]item=deleteidlist.split(","); for(inti=0;i<item.length;i++){ b=mb.delete(Integer.parseInt(item[i])); } obj.put("biaozhi",b); out=response.getWriter(); out.write(obj.toString()); }elseif("tree".equals(action)){ List<TreeNodes>treelist=mb.getnodes(); JSONObjectobj=newJSONObject();//定义一个json对象 obj.put("treelist",treelist); out=response.getWriter(); out.write(obj.toString()); }elseif("save".equals(action)){ Stringid=request.getParameter("id"); Stringzhuti=request.getParameter("zhuti"); Stringcontent=request.getParameter("content"); Mailboxmail=newMailbox(); mail.setS_id(Integer.parseInt(id));//收件人 mail.setS_name(Sqltools.findusername(Integer.parseInt(id)));//收件人姓名 mail.setP_name(cuser.getUsername());//发件人姓名 mail.setP_id(cuser.getId()); mail.setContent(content); mail.setTitle(zhuti); b=mb.addmailbox(mail); JSONObjectobj=newJSONObject(); obj.put("biaozhi",b); out=response.getWriter(); out.write(obj.toString()); } } /** *ThedoPostmethodoftheservlet.<br> * *Thismethodiscalledwhenaformhasitstagvaluemethodequalstopost. * *@paramrequesttherequestsendbytheclienttotheserver *@paramresponsetheresponsesendbytheservertotheclient *@throwsServletExceptionifanerroroccurred *@throwsIOExceptionifanerroroccurred */ @Override publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throwsServletException,IOException{ this.doGet(request,response); } }
dao层
packagecom.rc.dao; importjava.util.List; importcom.rc.entity.Mailbox; importcom.rc.entity.TreeNodes; importcom.rc.util.Page; publicinterfaceR_mailboxDAO{ publicList<Mailbox>getcostList(Pagepage);//获取全部的邮件 publicintgetcount();//获取数目 publicbooleandelete(Integerid);//删除 publicbooleanadd(Mailboxmail);//写信 publicbooleanupdate(Integerid);//修改 publicList<TreeNodes>getnodes();//树 publicbooleanaddmailbox(Mailboxmail);//添加邮件 }
daoimpl
<prename="code"class="html">ackagecom.rc.daoimpl; importjava.sql.Connection; importjava.sql.PreparedStatement; importjava.sql.ResultSet; importjava.sql.SQLException; importjava.sql.Statement; importjava.util.ArrayList; importjava.util.List; importcom.rc.dao.R_mailboxDAO; importcom.rc.dbutil.Sqltools; importcom.rc.entity.Mailbox; importcom.rc.entity.TreeNodes; importcom.rc.util.Page; importcom.rc.util.StringUtil; publicclassR_mailboxDAOimplimplementsR_mailboxDAO{ booleanb=true; Connectioncnn=null; PreparedStatementps=null; ResultSetrs=null; Statementst=null; Stringsql=""; @Override publicList<Mailbox>getcostList(Pagepage){ List<Mailbox>mailboxlist=newArrayList<Mailbox>();//定义一个数组 intstartsize=page.getCurrentPage()*page.getEverPage(); intendsize=(page.getCurrentPage()-1)*page.getEverPage()+1; sql="select*from(selecta1.*,rownumrnfrom(select*frommailboxorderbym_iddesc)a1WHERErownum<="+startsize+")wherern>="+endsize+""; try{ rs=Sqltools.excuteQuery(sql,null); while(rs.next()){ Mailboxmailbox=newMailbox(); mailbox.setMid(rs.getInt("m_id")); mailbox.setP_name(rs.getString("p_name")); mailbox.setS_name(rs.getString("r_name")); mailbox.setStatus(rs.getString("r_status")); mailbox.setContent(rs.getString("r_content")); mailbox.setTitle(rs.getString("r_title")); mailbox.setR_time(StringUtil.TimetoString(rs.getDate("r_time"))); mailboxlist.add(mailbox); } }catch(Exceptione){ Sqltools.close(rs,st,cnn); } returnmailboxlist.size()==0?null:mailboxlist; } @Override publicintgetcount(){ intcount=0; sql="selectcount(*)frommailbox"; try{ cnn=Sqltools.getConnection(); ps=cnn.prepareStatement(sql); rs=ps.executeQuery(); if(rs.next()){ count=rs.getInt(1); } }catch(Exceptione){ e.printStackTrace(); }finally{ Sqltools.close(rs,ps,cnn); } returncount; } @Override publicbooleandelete(Integerid){ sql="deletefrommailboxwherem_id=?"; try{ cnn=Sqltools.getConnection(); ps=cnn.prepareStatement(sql); ps.setInt(1,id); ps.executeUpdate(); }catch(Exceptione){ b=false; e.printStackTrace(); }finally{ Sqltools.aclose(rs,ps,cnn); } returnb; } @Override publicbooleanadd(Mailboxmail){ returnfalse; } @Override publicbooleanupdate(Integerid){ returnfalse; } @Override publicList<TreeNodes>getnodes(){//得到树节点 Stringsql="select*fromtree_tableorderbynid"; cnn=Sqltools.getConnection(); ArrayList<TreeNodes>treelist=newArrayList<TreeNodes>(); try{ ps=cnn.prepareStatement(sql); rs=ps.executeQuery(); while(rs.next()){ TreeNodesnode=newTreeNodes(); node.setNid(rs.getInt("nid")); node.setParentId(rs.getInt("parentid")); node.setNodeName(rs.getString("nodename")); treelist.add(node); } }catch(SQLExceptione){ e.printStackTrace(); }finally{ Sqltools.aclose(rs,ps,cnn); } returntreelist; } @Override publicbooleanaddmailbox(Mailboxmail){ sql="insertintomailbox(m_id,p_name,r_name,p_id,r_id,r_content,r_title,r_send,r_status,r_time)values(mailbox_id_seq.nextval,?,?,?,?,?,?,?,?,sysdate)"; try{ cnn=Sqltools.getConnection(); ps=cnn.prepareStatement(sql); ps.setString(1,mail.getP_name()); ps.setString(2,mail.getS_name()); ps.setInt(3,mail.getP_id()); ps.setInt(4,mail.getS_id()); ps.setString(5,mail.getContent()); ps.setString(6,mail.getTitle()); ps.setString(7,"0");//是否发送 ps.setString(8,"3");//是否读取 ps.executeUpdate(); }catch(Exceptione){ b=false; e.printStackTrace(); }finally{ Sqltools.aclose(rs,ps,cnn); } returnb; } }
jsp页面
<prename="code"class="html"><%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%> <% Stringpath=request.getContextPath(); StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"> <html> <head> <basehref="<%=basePath%>"> <title>MyJSP'mailbox.jsp'startingpage</title> <metahttp-equiv="pragma"content="no-cache"> <metahttp-equiv="cache-control"content="no-cache"> <metahttp-equiv="expires"content="0"> <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"> <metahttp-equiv="description"content="Thisismypage"> <%@tagliburi="http://java.sun.com/jsp/jstl/core"prefix="c"%> <head> <linkrel="stylesheet"type="text/css"href="${pageContext.request.contextPath}/css/bootstrap.min.css"> <linkrel="stylesheet"type="text/css"href="${pageContext.request.contextPath}/css/admin.css"> <linkrel="stylesheet"type="text/css"href="${pageContext.request.contextPath}/js/sweetalert.css"> <linkrel="stylesheet"type="text/css"href="/rccwgl/components/dtree/dtree.css"> </head> <body> <!--tab导航列表--> <ulid="myTab"class="navnav-tabs"> <liclass="active"><ahref="#home"data-toggle="tab"class="btnbtn-primary">邮件列表</a></li> <li><ahref="#ios"data-toggle="tab"class="btnbtn-success">未读邮件</a></li> <li><ahref="#gz"data-toggle="tab"class="btnbtn-warning">已读邮件</a></li> <li><ahref="#cg"data-toggle="tab"class="btnbtn-info">草稿列表</a></li> <liclass="dropdown"> <ahref="#"id="myTabDrop1"class="dropdown-togglebtn-danger"data-toggle="dropdown">功能开发中 <bclass="caret"></b> </a> <ulclass="dropdown-menu"role="menu"aria-labelledby="myTabDrop1"> <li><ahref="#jmeter"tabindex="-1"data-toggle="tab">开发一</a></li> <li><ahref="#ejb"tabindex="-1"data-toggle="tab">开发二</a></li> </ul> </li> </ul> <!--邮件内容显示--> <divid="myTabContent"class="tab-content"> <!--邮件列表--> <divclass="tab-panefadeinactive"id="home"> <!--<formmethod="post"action="R_costServlet?action=plpay_a"onsubmit="returnpldelete();">--> <divclass="mainContent"> <inputid="pl"type="button"class="btnbtn-info"style="margin-top:50px;"onclick="pl()"value="批量删除"> <buttonclass="btnbtn-primarybtn-bgpull-right"style="margin-top:50px;"data-toggle="modal"data-target="#myModal"onclick="addmail()">写邮件</button> <divclass="row"> <divclass="content"> <tableclass="tabletable-hovertable-bordered"> <thead> <tr> <tdalign="left"><inputtype="checkbox"name="qx"onclick="quanxuan()">全选</td> <td>主题</td> <td>发件人</td> <td>邮件内容</td> <td>接收时间</td> <td>是否读取</td> <td>操作</td> </tr> </thead> <tbodyid="list"></tbody> </table> <divid="pageinfo"style="height:200px;"></div> </div> </div> </div> <!--</form>--> </div> <!--未读邮件--> <divclass="tab-panefade"id="ios"> <!--<formmethod="post"action="R_costServlet?action=plpay_a"onsubmit="returnpldelete();">--> <divclass="mainContent"> <inputtype="submit"value="批量删除"class="btnbtn-info"style="margin-top:50px;"> <inputtype="submit"value="写邮件"class="btnbtn-primarybtn-bgpull-right"style="margin-top:50px;"> <divclass="row"> <divclass="content"> <tableclass="tabletable-hovertable-bordered"> <thead> <tr> <tdalign="left"><inputtype="checkbox"name="qx"onclick="quanxuan(this)">全选</td> <td>序号</td> <td>发件人</td> <td>邮件内容</td> <td>接收时间</td> <td>是否读取</td> <td>编辑</td> </tr> </thead> <tbodyid="list1"></tbody> </table> <divid="pageinfo1"style="height:200px;"></div> </div> </div> </div> <!--</form>--> </div> <!--已读邮件--> <divclass="tab-panefade"id="gz"> <!--<formmethod="post"action="R_costServlet?action=plpay_a"onsubmit="returnpldelete();">--> <divclass="mainContent"> <inputtype="submit"value="批量删除"class="btnbtn-info"style="margin-top:50px;"> <inputtype="submit"value="写邮件"class="btnbtn-primarybtn-bgpull-right"style="margin-top:50px;"> <divclass="row"> <divclass="content"> <tableclass="tabletable-hovertable-bordered"> <thead> <tr> <tdalign="left"><inputtype="checkbox"name="qx"onclick="quanxuan(this)">全选</td> <td>序号</td> <td>发件人</td> <td>邮件内容</td> <td>接收时间</td> <td>是否读取</td> <td>编辑</td> </tr> </thead> <tbodyid="list2"></tbody> </table> <divid="pageinfo2"style="height:200px;"></div> </div> </div> </div> <!--</form>--> </div> <divclass="tab-panefade"id="jmeter"> <divclass="mainContent"> <p>jMeter是一款开源的测试软件。它是100%纯Java应用程序,用于负载和性能测试。</p> </div> </div> <divclass="tab-panefade"id="ejb"> <p>EnterpriseJavaBeans(EJB)是一个创建高度可扩展性和强大企业级应用程序的开发架构,部署在兼容应用程序服务器(比如JBOSS、WebLogic等)的J2EE上。 </p> </div> <!--草稿列表--> <divclass="tab-panefade"id="cg"> <!--<formmethod="post"action="R_costServlet?action=plpay_a"onsubmit="returnpldelete();">--> <divclass="mainContent"> <inputtype="submit"value="批量删除"class="btnbtn-info"style="margin-top:50px;"> <inputtype="submit"value="写邮件"class="btnbtn-primarybtn-bgpull-right"style="margin-top:50px;"> <divclass="row"> <divclass="content"> <tableclass="tabletable-hovertable-bordered"> <thead> <tr> <tdalign="left"><inputtype="checkbox"name="qx"onclick="quanxuan(this)">全选</td> <td>序号</td> <td>发件人</td> <td>邮件内容</td> <td>接收时间</td> <td>是否读取</td> <td>编辑</td> </tr> </thead> <tbodyid="list3"></tbody> </table> <divid="pageinfo3"style="height:200px;"></div> </div> </div> </div> <!--</form>--> </div> <!----> </div> <!--写邮件的弹出框--> <divid="alls"style=""> <divclass="container"> <divclass="modalfade"id="myModal"tabindex="-1"role="dialog"aria-labelledby="myModalLabel"> <divclass="modal-dialog"role="document"style="width:800px"> <divclass="modal-content"> <divclass="modal-header"> <buttontype="button"class="close"data-dismiss="modal"aria-label="Close"><spanaria-hidden="true">×</span></button> <h4class="modal-title"id="myModalLabel">写邮件</h4> </div> <divclass="modal-body"> <divclass="form-group"> <labelfor="txt_departmentname">主题</label> <inputtype="text"name="txt_departmentname"class="form-control"id="zhuti"placeholder="部门名称"> </div> <divclass="form-group"> <divid="treediv"style="display:none;overflow:scroll;width:150px;height:300px;padding:5px;background:#fff;color:#fff;border:1pxsolid#cccccc"> <inputtype="text"name="txt_parentdepartment"class="form-control"id="menu_parent_name"> </div> </div> <divclass="form-group"> <labelfor="txt_departmentname">收件人</label> <inputtype="text"name="txt_departmentname"class="form-control"id="setvalue"placeholder="部门名称"> <inputtype="hidden"id="menu_parent"name="menu_parent"><!--父菜单id--> </div> <divclass="form-group"> <labelfor="txt_statu">邮件内容</label> <textarearows="8"class="form-control"id="editor_id"name="content"></textarea> </div> </div> <divclass="modal-footer"> <buttontype="button"class="btnbtn-success"id="send"data-dismiss="modal"><spanclass="glyphiconglyphicon-envelope"aria-hidden="true"></span>发送</button> <buttontype="button"class="btnbtn-default"id="btn_close"data-dismiss="modal"><spanclass="glyphiconglyphicon-remove"aria-hidden="true"></span>关闭</button> <buttontype="button"id="btn_submit"class="btnbtn-primary"data-dismiss="modal"><spanclass="glyphiconglyphicon-floppy-disk"aria-hidden="true"></span>保存</button> </div> </div> </div> </div> </div> </div> <scriptsrc="/rccwgl/js/jquery-3.1.0.min.js"></script> <scriptsrc="/rccwgl/js/bootstrap.min.js"></script> <scripttype="text/javascript"src="js/bootstrap-paginator.js"></script> <scripttype="text/javascript"src="js/sweetalert.min.js"></script> <scripttype="text/javascript"src="js/sweetalert-dev.js"></script> <scriptsrc="/rccwgl/mailbox/js/mailbox.js"></script> <scripttype="text/javascript"charset="utf-8"src="mailbox/kindeditor-4.1.10/kindeditor.js"></script> <scriptcharset="utf-8"src="mailbox/kindeditor-4.1.10/lang/zh_CN.js"></script> <scripttype="text/javascript"charset="utf-8"src="/rccwgl/mailbox/js//kdreply.js"></script> <SCRIPTtype="text/javascript"src="/rccwgl/components/dtree/dtree.js"></SCRIPT> </body> </html>
js
<prename="code"class="html">$(function(){//初始化页面 page1(); initTree(); shouwtree(); $('#treediv').mouseleave(function(){//在鼠标离开选择树的时候,选择书影藏 //alert("进来了"); $("#treediv").hide(); }); }); functionDelete(mid){ swal({title:"你确定要进行该操作?", text:"Youwillnotbeabletorecoverthisimaginaryfile!", type:"warning", showCancelButton:true, confirmButtonColor:"#DD6B55", confirmButtonText:"是的,删除!", cancelButtonText:"不,取消", closeOnConfirm:false, closeOnCancel:false}, function(isConfirm){ if(isConfirm){ varaction="delete"; $.ajax({ type:"post", url:"MailBoxServlet", datatype:'json', data:{action:action,id:mid,a:Math.random()}, success:function(data){ vard=eval('('+data+')'); if(d.biaozhi==true){ swal("删除!","删除成功","success"); //window.location.reload();这种方式无法显示成功提示 $("#list").empty(); page1(); }else{ swal("Deleted!","删除失败","error"); } } }); } else{ swal("","你已经取消的该操作","error"); } }); } functionEdit(mid){ alert(mid); } functionpl(){//批量删除 varcheckedList=newArray(); varids=""; if($("input[name='deleteCusersid']:checked").length>0){ $("input[name='deleteCusersid']").each(function(){ if($(this).prop("checked")){//如果要未选中的==false就可以了 //ids+=$(this).val()+","; checkedList.push($(this).val()); } }); swal({title:"你确定要删除这"+checkedList.length+"行?", //text:"Youwillnotbeabletorecoverthisimaginaryfile!", type:"warning", showCancelButton:true, confirmButtonColor:"#DD6B55", confirmButtonText:"是的,确定删除!", cancelButtonText:"不,取消", closeOnConfirm:false, closeOnCancel:false}, function(isConfirm){ if(isConfirm){ varaction="pldelete"; $.ajax({ type:"post", url:"MailBoxServlet", datatype:'json', data:{action:action,a:Math.random(),deleteidlist:checkedList.toString()}, success:function(data){ vard=eval('('+data+')'); if(d.biaozhi==true){ swal("删除!","批量删除成功","success"); $("input[name='deleteCusersid']").prop("checked",false);//将其他有对号的清除 $("input[name='qx']").prop("checked",false);//将全选的对号清除 $("#list").empty(); page1(); //window.location.reload(); }else{ swal("Deleted!","删除失败","error"); } } }); } else{ swal("","你已经取消的该操作","error"); $("input[name='qx']").prop("checked",false); $("input[name='deleteCusersid']").prop("checked",false); } }); }else{ swal("失败!","你必须选择至少一行进行该操作!","info"); } } functionquanxuan(){//全选与全不选 if($("input[name='qx']").prop("checked")){ varcheckbox=$("input[name='deleteCusersid']"); checkbox.prop("checked",true); }else{ varcheckbox=$("input[name='deleteCusersid']"); checkbox.prop("checked",false); } } functionaddmail(){//写邮件 $("#btn_submit").click(function(){ varid=$("#menu_parent").val(); varzhuti=$("#zhuti").val();//获取主题 varcontent=$("#editor_id").val();//获取内容 if(zhuti==""||id==""){ if(zhuti==""){ swal("主题不能为空"); }else{ swal("收件人不能为空"); } returnfalse; }else{ varaction="save"; $.ajax({ url:"MailBoxServlet", data:'json', type:"post", data:{action:action,id:id,content:content,zhuti:zhuti,a:Math.random()}, success:function(data){ if(data!=null){ vard=eval('('+data+')'); if(d.biaozhi){ swal("邮件编写成功"); }else{ swal("邮件编写失败"); } } $("#zhuti").val("");//关闭的时候将所有的值制空 $("#setvalue").val(""); KindEditor.instances[0].html('');//专门的将textarea值置空0表示第一个KindEditor编辑器对象 $("#list").empty();//置空 page1();//异步刷新页面 } }); } //swal("关闭"); }); $("#btn_close").click(function(){ $("#zhuti").val("");//关闭的时候将所有的值制空 $("#setvalue").val(""); KindEditor.instances[0].html('');//专门的将textarea值置空0表示第一个KindEditor编辑器对象 swal("关闭"); }); $("#send").click(function(){ swal("发送成功"); }); } functioninitTree(){//初始化树 varaction="tree"; mydtree=newdTree('mydtree','${pageContext.request.contextPath}/style/default/images/dtree/','no','no'); mydtree.add(0, -1, "根目录", "javascript:setvalue('0','根目录')", "根目录", "_self", true); $.ajax({ url:"MailBoxServlet", data:'json', type:"post", data:{action:action,a:Math.random()}, success:function(data){ if(data!=null){ $.each(eval("("+data+")").treelist,function(index,item){ varid=item.nid; varpid=item.parentId; varnodesname=item.nodeName; mydtree.add(id,pid,nodesname,"javascript:setvalue('"+id+"','"+nodesname+"')",nodesname,"_self",false); }); //document.write(mydtree); //将树添加到指定div(jQuery) $("#treediv").html(mydtree.toString()); } } }); } functionshouwtree(){ $("#setvalue").click(function(){ $("#treediv").show(); }); } functionsetvalue(id,name){ $("#setvalue").val(name); $("#menu_parent").val(id); $("#treediv").hide(); } functionpage1(){ varpageNumber=1;//默认初始页为第一页 varaction="page";//定义一个要进入的条件 $.ajax({//ajax请求 url:"MailBoxServlet", data:'json', type:"Post", data:{action:action,pageNumber:pageNumber,a:Math.random()},//参数 success:function(data){//请求成功的方法 if(data!=null){ $.each(eval("("+data+")").mailbox,function(index,item){//遍历返回的json varhtml="<tr><td><inputtype='checkbox'name='deleteCusersid'value='"+item.mid+"'/></td><td>"+item.title+"</td><td>"+item.p_name+"</td><td>"+item.content+"</td><td>"+item.r_time+"</td><td>"+item.status+"</td><td>"; m1="编辑"; m2="删除"; html2="<divclass='btn-group'><buttononclick='Edit("+item.mid+")'class='btnbtn-infobtn-sm'><spanclass='glyphiconglyphicon-editicon-white'></span>"+m1+"</button>" +"<buttononclick='Delete("+item.mid+")'class='btnbtn-dangerbtn-sm'><spanclass='glyphiconglyphicon-trashicon-white'></span>"+m2+"</button>" +"</div></td></tr>"; html+=html2; $("#list").append(html); }); varpageCount=eval("("+data+")").Page[0].totalPage;//取到pageCount的值(把返回数据转成object类型) varcurrentPage=eval("("+data+")").Page[0].currentPage;//得到urrentPage varoptions={ bootstrapMajorVersion:2,//版本 currentPage:currentPage,//当前页数 totalPages:pageCount,//总页数 //numberOfPages:10, itemTexts:function(type,page,current){ switch(type){ case"first": return"首页"; case"prev": return"上一页"; case"next": return"下一页"; case"last": return"末页"; case"page": returnpage; } }, onPageClicked:function(event,originalEvent,type,page){ $("#list").empty(); $.ajax({ url:"MailBoxServlet?pageNumber="+page, type:"Post", data:{action:"page",a:Math.random()}, success:function(data1){ if(data1!=null){ $.each(eval("("+data1+")").mailbox,function(index,item){//遍历返回的json varhtml="<tr><td><inputtype='checkbox'name='deleteCusersid'value='"+item.mid+"'/></td><td>"+item.mid+"</td><td>"+item.p_name+"</td><td>"+item.content+"</td><td>"+item.r_time+"</td><td>"+item.status+"</td><td>"; m1="编辑"; m2="删除"; html2="<divclass='btn-group'><buttononclick='Edit("+item.mid+")'class='btnbtn-infobtn-sm'><spanclass='glyphiconglyphicon-editicon-white'></span>"+m1+"</button>" +"<buttononclick='Delete("+item.mid+")'class='btnbtn-dangerbtn-sm'><spanclass='glyphiconglyphicon-trashicon-white'></span>"+m2+"</button>" +"</div></td></tr>"; html+=html2; $("#list").append(html); }); } } }); } }; $('#pageinfo').bootstrapPaginator(options); } } }); }
以上所述是小编给大家介绍的BootStrap实现邮件列表的分页和模态框添加邮件的功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!