Manager11.java~2~
上传用户:toby828
上传日期:2015-06-26
资源大小:8558k
文件大小:6k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package com.action;
  2. import org.apache.struts.action.*;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import com.actionForm.ManagerForm;
  6. import com.dao.ManagerDAO;
  7. public class Manager11 extends Action {
  8.     private ManagerDAO managerDAO = null;
  9.     public Manager11() {
  10.         this.managerDAO = new ManagerDAO();
  11.     }
  12.     public ActionForward perform(ActionMapping actionMapping,
  13.                                  ActionForm actionForm,
  14.                                  HttpServletRequest servletRequest,
  15.                                  HttpServletResponse servletResponse) {
  16.         String action = servletRequest.getParameter("action");
  17.         System.out.println("获取的查询字符串:" + action);
  18.         if (action == null || "".equals(action)) {
  19.             return actionMapping.findForward("error");
  20.         }
  21.        /*
  22.         else if ("login".equals(action)) {
  23.             return managerLogin(actionMapping, actionForm, servletRequest,
  24.                                 servletResponse);
  25.         } else if ("managerAdd".equals(action)) {
  26.             return managerAdd(actionMapping, actionForm, servletRequest,
  27.                               servletResponse);
  28.         } else if ("managerQuery".equals(action)) {
  29.             return managerQuery(actionMapping, actionForm, servletRequest,
  30.                                 servletResponse);
  31.         } else if ("managerModifyQuery".equals(action)) {
  32.             return managerModifyQuery(actionMapping, actionForm, servletRequest,
  33.                                       servletResponse);
  34.         } else if ("managerModify".equals(action)) {
  35.             return managerModify(actionMapping, actionForm, servletRequest,
  36.                                  servletResponse);
  37.         } else if ("managerDel".equals(action)) {
  38.             return managerDel(actionMapping, actionForm, servletRequest,
  39.                               servletResponse);
  40.         }
  41.         */
  42.         return actionMapping.findForward("error");
  43.     }
  44.     //管理员身份验证
  45.     public ActionForward managerLogin(ActionMapping actionMapping,
  46.                                       ActionForm actionForm,
  47.                                       HttpServletRequest servletRequest,
  48.                                       HttpServletResponse servletResponse) {
  49.         ManagerForm managerForm = (ManagerForm) actionForm;
  50.         managerForm.setName(managerForm.getName());
  51.         managerForm.setPwd(managerForm.getPwd());
  52.         int ret = managerDAO.checkManager(managerForm);
  53.         System.out.print("验证结果ret的值:" + ret);
  54.         if (ret == 1) {
  55.             return actionMapping.findForward("managerLoginok");
  56.         } else {
  57.             return actionMapping.findForward("mange rLoginfilse");
  58.         }
  59.     }
  60. /*
  61.     //查询管理员信息
  62.     private ActionForward managerQuery(ActionMapping actionMapping,
  63.                                        ActionForm actionForm,
  64.                                        HttpServletRequest servletRequest,
  65.                                        HttpServletResponse servletResponse) {
  66.         String str = null;
  67.         servletRequest.setAttribute("managerQuery", managerDAO.query(str));
  68.         return actionMapping.findForward("managerQuery");
  69.     }
  70.     //添加管理员信息
  71.     private ActionForward managerAdd(ActionMapping actionMapping,
  72.                                      ActionForm actionForm,
  73.                                      HttpServletRequest servletRequest,
  74.                                      HttpServletResponse servletResponse) {
  75.         ManagerForm managerForm = (ManagerForm) actionForm;
  76.         managerForm.setName(managerForm.getName());
  77.         managerForm.setPwd(managerForm.getPwd());
  78.         int ret = managerDAO.insert(managerForm);
  79.         if (ret == 1) {
  80.             return actionMapping.findForward("managerAdd");
  81.         } else {
  82.             return actionMapping.findForward("error");
  83.         }
  84.     }
  85.     //查询修改管理员信息
  86.     private ActionForward managerModifyQuery(ActionMapping actionMapping,
  87.                                              ActionForm actionForm,
  88.                                              HttpServletRequest servletRequest,
  89.                                              HttpServletResponse
  90.                                              servletResponse) {
  91.         ManagerForm managerForm = (ManagerForm) actionForm;
  92.         managerForm.setId(Integer.valueOf(servletRequest.getParameter("id")));
  93.         servletRequest.setAttribute("managerQueryif",
  94.                                     managerDAO.query_update(managerForm));
  95.         return actionMapping.findForward("managerQueryModify");
  96.     }
  97.     //修改管理员信息
  98.     private ActionForward managerModify(ActionMapping actionMapping,
  99.                                         ActionForm actionForm,
  100.                                         HttpServletRequest servletRequest,
  101.                                         HttpServletResponse servletResponse) {
  102.         ManagerForm managerForm = new ManagerForm();
  103.         managerForm.setName(managerForm.getName());
  104.         managerForm.setPwd(managerForm.getPwd());
  105.         int ret = managerDAO.update(managerForm);
  106.         if (ret == 0) {
  107.             return actionMapping.findForward("error");
  108.         } else {
  109.             return actionMapping.findForward("managerModify");
  110.         }
  111.     }
  112.     //删除管理员信息
  113.     private ActionForward managerDel(ActionMapping actionMapping,
  114.                                      ActionForm actionForm,
  115.                                      HttpServletRequest servletRequest,
  116.                                      HttpServletResponse servletResponse) {
  117.         ManagerForm managerForm = (ManagerForm) actionForm;
  118.         managerForm.setId(Integer.valueOf(servletRequest.getParameter("id")));
  119.         int ret = managerDAO.delete(managerForm);
  120.         if (ret == 0) {
  121.             return actionMapping.findForward("error");
  122.         } else {
  123.             return actionMapping.findForward("managerDel");
  124.         }
  125.     }
  126. */
  127. }