Package com.postusermiddlemodule.servlet

Source Code of com.postusermiddlemodule.servlet.TbPostUserMiddleServlet

package com.postusermiddlemodule.servlet;
import com.postusermiddlemodule.bean.TbPostUserMiddle;
import com.postusermiddlemodule.dao.*;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import util.*;

public class TbPostUserMiddleServlet extends HttpServlet{
    public void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        String method = request.getParameter("method")==null?"":request.getParameter("method");
        if("add".equals(method)){
        int postId=Integer.parseInt(request.getParameter("postId"));
        int userId=Integer.parseInt(request.getParameter("userId"));
        String createTime=request.getParameter("createTime");

            if(new TbPostUserMiddleDAO().add(new TbPostUserMiddle(postId,userId,createTime))){
            request.getSession().setAttribute("result", "添加成功");
            }else{           
            request.getSession().setAttribute("result", "添加失败");
            }
             request.getSession(true).setAttribute("tbPostUserMiddleList",new TbPostUserMiddleDAO().getTbPostUserMiddleAll());
            response.sendRedirect("PostusermiddleModule/TbPostUserMiddleList.jsp");
        }
        if("del".equals(method)){
            if(UtilDAO.delin("Tb_PostUserMiddle", "PostUserMiddleId", request.getParameter("delIds"))){           
            request.getSession().setAttribute("result", "删除成功");
            }else{           
            request.getSession().setAttribute("result", "删除失败");
            }
             request.getSession(true).setAttribute("tbPostUserMiddleList",new TbPostUserMiddleDAO().getTbPostUserMiddleAll());
            response.sendRedirect("PostusermiddleModule/TbPostUserMiddleList.jsp");
        }
        if("edit".equals(method)){
        int postUserMiddleId=Integer.parseInt(request.getParameter("postUserMiddleId"));
        int postId=Integer.parseInt(request.getParameter("postId"));
        int userId=Integer.parseInt(request.getParameter("userId"));
        String createTime=request.getParameter("createTime");

            if(new TbPostUserMiddleDAO().add(new TbPostUserMiddle(postUserMiddleId,postId,userId,createTime))){
            request.getSession().setAttribute("result", "修改成功");
            }else{           
            request.getSession().setAttribute("result", "修改失败");
            }
             request.getSession(true).setAttribute("tbPostUserMiddleList",new TbPostUserMiddleDAO().getTbPostUserMiddleAll());
            response.sendRedirect("PostusermiddleModule/TbPostUserMiddleList.jsp");
        }
        if ("list".equals(method)) {
             request.getSession(true).setAttribute("tbPostUserMiddleList",new TbPostUserMiddleDAO().getTbPostUserMiddleAll());
            response.sendRedirect("PostusermiddleModule/TbPostUserMiddleList.jsp");
          }
        if ("listById".equals(method)) {
             request.getSession(true).setAttribute("tbPostUserMiddle",new TbPostUserMiddleDAO().getTbPostUserMiddleByPostUserMiddleId(Integer.parseInt(request.getParameter("postUserMiddleId"))));
            response.sendRedirect("PostusermiddleModule/TbPostUserMiddleOperate.jsp");
      }
        if("showadd".equals(method)){
           
            response.sendRedirect("PostusermiddleModule/TbPostUserMiddleOperate.jsp");
        }
    }
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.processRequest(request, response);
    }// end method doGet
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.processRequest(request, response);
    }// end method doPost
}
TOP

Related Classes of com.postusermiddlemodule.servlet.TbPostUserMiddleServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.