BootStrap实现邮件列表的分页和模态框添加邮件的功能实现邮件列表的分页和模态框添加邮件的功能
主要介绍了bootstrap分页,模态框,实现邮件列表的分页,和模态框添加邮件的功能的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
废话不多说具体代码如下所示:
package com.rc.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sf.json.JSONObject;
import com.rc.dao.R_mailboxDAO;
import com.rc.daoimpl.R_mailboxDAOimpl;
import com.rc.dbutil.Sqltools;
import com.rc.entity.Mailbox;
import com.rc.entity.R_user;
import com.rc.entity.TreeNodes;
import com.rc.util.Page;
import com.rc.util.PageUtil;
public class MailBoxServlet extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
String action =request.getParameter("action");
HttpSession hs = request.getSession(false); //读取登录人员session
R_user cuser =(R_user)hs.getAttribute("user");
PrintWriter out = null;
R_mailboxDAO mb = new R_mailboxDAOimpl();
boolean b = true;
if("page".equals(action)){//查询所有
int pageNumber = 0;
String PageNumberstr = request.getParameter("pageNumber");//从页面获取的当前页
int count =mb.getcount();
if(PageNumberstr == null||"".equals(PageNumberstr)){
pageNumber= 1;
}else{
pageNumber = Integer.parseInt(PageNumberstr);//否则强转
}
List <Page> pages = new ArrayList<Page>();
Page page = PageUtil.createPage(5, count, pageNumber);
pages.add(page);
List<Mailbox> mailboxlist = mb.getcostList(page);
JSONObject obj = new JSONObject();//定义一个json对象
obj.put("mailbox", mailboxlist);
obj.put("Page", pages);
out = response.getWriter();
out.write(obj.toString());
}else if("delete".equals(action)){//删除操作
String mid = request.getParameter("id");
JSONObject obj = new JSONObject();
b =mb.delete(Integer.parseInt(mid));//用boolean接收
obj.put("biaozhi",b);
out = response.getWriter();
out.write(obj.toString());
}else if("edit".equals(action)){//弹出编辑页面
}else if("tedit".equals(action)){//提交编辑信息
}else if("pldelete".equals(action)){//批量删除
JSONObject obj = new JSONObject();
String deleteidlist = request.getParameter("deleteidlist");
String[] item = deleteidlist.split(",");
for (int i = 0; i < item.length; i++) {
b =mb.delete(Integer.parseInt(item[i]));
}
obj.put("biaozhi",b);
out = response.getWriter();
out.write(obj.toString());
}else if("tree".equals(action)){
List<TreeNodes> treelist = mb.getnodes();
JSONObject obj = new JSONObject();//定义一个json对象
obj.put("treelist", treelist);
out = response.getWriter();
out.write(obj.toString());
}else if("save".equals(action)){
String id = request.getParameter("id");
String zhuti = request.getParameter("zhuti");
String content = request.getParameter("content");
Mailbox mail = new Mailbox();
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);
JSONObject obj = new JSONObject();
obj.put("biaozhi", b);
out = response.getWriter();
out.write(obj.toString());
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}