DelboxServlet.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:2k
- package com.softeem.webmail.delbox;
- 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.delbox.GetDelboxInfo;
- public class DelboxServlet 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;charset=UTF-8");
- request.setCharacterEncoding("UTF-8");
- User user = (User) request.getSession(false).getAttribute("user");
- String username = user.getUsername();
- // String username="sad";
- String page = request.getParameter("page");
- List list = GetDelboxInfo.getInfo(username);
- //拿到数据的总条数
- int size = list.size();
- //定义一个i作为有多少页
- int i = 0;
- if(size%5==0){
- i = size/5;
- }else{
- i = size/5+1;
- }
- //定义一个List
- List delbox = null;
- if(page==null){
- delbox = GetDelboxInfo.getResult(list, 1);
- request.setAttribute("currentpage", 1);
- }else{
- delbox = GetDelboxInfo.getResult(list, Integer.parseInt(page));
- request.setAttribute("currentpage", Integer.parseInt(page));
- }
- request.setAttribute("total", size);
- request.setAttribute("lastpage", i);
- request.setAttribute("delbox", delbox);
- request.getRequestDispatcher("delbox.jsp").forward(request, response);
- }
-
- }