SearchManager.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:2k
- package com.softeem.webmail.receivemanage;
- 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.tags.PageBean;
- public class SearchManager extends HttpServlet {
-
- public SearchManager() {
- super();
- }
- public void destroy() {
- super.destroy(); // Just puts "destroy" string in log
- // Put your code here
- }
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
-
- }
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String te=request.getParameter("page");
- List temp=null;
- List<Mail> mails=(List<Mail>) request.getAttribute("searchMails");
- 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("searchlist.jsp").forward(request, response);
-
- }
-
- public void init() throws ServletException {
- // Put your code here
- }
- }