Package com.rolemodule.servlet

Source Code of com.rolemodule.servlet.TbRoleServlet

package com.rolemodule.servlet;
import com.rolemodule.bean.TbRole;
import com.rolemodule.dao.*;

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

public class TbRoleServlet 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)){
        String roleName=request.getParameter("roleName");
        int userId=Integer.parseInt(request.getParameter("userId"));
        String roleMemo=request.getParameter("roleMemo");
        String createTime=request.getParameter("createTime");

            if(new TbRoleDAO().add(new TbRole(roleName,userId,roleMemo,createTime))){
            request.getSession().setAttribute("result", "添加成功");
            }else{           
            request.getSession().setAttribute("result", "添加失败");
            }
             request.getSession(true).setAttribute("tbRoleList",new TbRoleDAO().getTbRoleAll());
            response.sendRedirect("RoleModule/TbRoleList.jsp");
        }
        if("del".equals(method)){
            if(UtilDAO.delin("Tb_Role", "RoleId", request.getParameter("delIds"))){           
            request.getSession().setAttribute("result", "删除成功");
            }else{           
            request.getSession().setAttribute("result", "删除失败");
            }
             request.getSession(true).setAttribute("tbRoleList",new TbRoleDAO().getTbRoleAll());
            response.sendRedirect("RoleModule/TbRoleList.jsp");
        }
        if("edit".equals(method)){
        int roleId=Integer.parseInt(request.getParameter("roleId"));
        String roleName=request.getParameter("roleName");
        int userId=Integer.parseInt(request.getParameter("userId"));
        String roleMemo=request.getParameter("roleMemo");
        String createTime=request.getParameter("createTime");

            if(new TbRoleDAO().add(new TbRole(roleId,roleName,userId,roleMemo,createTime))){
            request.getSession().setAttribute("result", "修改成功");
            }else{           
            request.getSession().setAttribute("result", "修改失败");
            }
             request.getSession(true).setAttribute("tbRoleList",new TbRoleDAO().getTbRoleAll());
            response.sendRedirect("RoleModule/TbRoleList.jsp");
        }
        if ("list".equals(method)) {
             request.getSession(true).setAttribute("tbRoleList",new TbRoleDAO().getTbRoleAll());
            response.sendRedirect("RoleModule/TbRoleList.jsp");
          }
        if ("listById".equals(method)) {
             request.getSession(true).setAttribute("tbRole",new TbRoleDAO().getTbRoleByRoleId(Integer.parseInt(request.getParameter("roleId"))));
            response.sendRedirect("RoleModule/TbRoleOperate.jsp");
      }
        if("showadd".equals(method)){
           
            response.sendRedirect("RoleModule/TbRoleOperate.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.rolemodule.servlet.TbRoleServlet

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.