ReceiveBox.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:2k
- package com.softeem.webmail.receive;
- import java.io.IOException;
- import java.util.List;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.softeem.webmail.beans.receive.User;
- import com.softeem.webmail.dao.mail.Mail;
- import com.softeem.webmail.dao.mail.MailDAO;
- import com.softeem.webmail.tags.PageBean;
- public class ReceiveBox extends HttpServlet {
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
-
- }
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- //
- User user=(User) request.getSession(false).getAttribute("user");
- String username=user.getUsername();
- List temp=null;
- // String username="sad";
- String te=request.getParameter("page");
- List<Mail> mails=MailDAO.getMailsByUsername(username);
- System.out.println(mails.size());
- if(te==null){
- PageBean pb=new PageBean(1,mails.size(),10);
- if(mails.size()>10){
- temp=mails.subList(0, 10);
- }
- else{
- temp=mails.subList(0, mails.size());
- }
- request.setAttribute("pagebean", pb);
- }
- else{
- int page=Integer.parseInt(te);
- System.out.println(te+"<><><>");
- PageBean pb=new PageBean(page,mails.size(),10);
- if(page*10<=pb.getTotal_count()&&(page-1)*10>=0){
- temp=mails.subList((page-1)*10, page*10);
- }
- else{
- if((page-1)*10>=0){
- temp=mails.subList((page-1)*10, pb.getTotal_count());
- }
- else{
- temp=mails.subList(0, pb.getTotal_count());
- }
- }
- request.setAttribute("pagebean", pb);
- }
- request.setAttribute("mailsinfo", temp);
- request.getRequestDispatcher("list1.jsp").forward(request, response);
- }
-
-
- }