ReceiveMailShow.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:2k
- package com.softeem.webmail.receive;
- import java.io.IOException;
- import java.io.PrintWriter;
- 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 ReceiveMailShow 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 {
- response.setContentType("text/html");
- User user=(User) request.getSession(false).getAttribute("user");
- String username=user.getUsername();
- List temp=null;
-
- String te=request.getParameter("page");
- List<Mail> mails=MailDAO.getMailsByUsername(username);
- int msize=mails.size();
- System.out.println(msize);
- if(te==null){
- PageBean pb=new PageBean(1,msize,10);
- if(msize>10){
- temp=mails.subList(0, 10);
- }
- else{
- temp=mails.subList(0, msize);
- }
- 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("list.jsp").forward(request, response);
- }
- }