Manager11.java~2~
上传用户:toby828
上传日期:2015-06-26
资源大小:8558k
文件大小:6k
- package com.action;
- import org.apache.struts.action.*;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.actionForm.ManagerForm;
- import com.dao.ManagerDAO;
- public class Manager11 extends Action {
- private ManagerDAO managerDAO = null;
- public Manager11() {
- this.managerDAO = new ManagerDAO();
- }
- public ActionForward perform(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- String action = servletRequest.getParameter("action");
- System.out.println("获取的查询字符串:" + action);
- if (action == null || "".equals(action)) {
- return actionMapping.findForward("error");
- }
- /*
- else if ("login".equals(action)) {
- return managerLogin(actionMapping, actionForm, servletRequest,
- servletResponse);
- } else if ("managerAdd".equals(action)) {
- return managerAdd(actionMapping, actionForm, servletRequest,
- servletResponse);
- } else if ("managerQuery".equals(action)) {
- return managerQuery(actionMapping, actionForm, servletRequest,
- servletResponse);
- } else if ("managerModifyQuery".equals(action)) {
- return managerModifyQuery(actionMapping, actionForm, servletRequest,
- servletResponse);
- } else if ("managerModify".equals(action)) {
- return managerModify(actionMapping, actionForm, servletRequest,
- servletResponse);
- } else if ("managerDel".equals(action)) {
- return managerDel(actionMapping, actionForm, servletRequest,
- servletResponse);
- }
- */
- return actionMapping.findForward("error");
- }
- //管理员身份验证
- public ActionForward managerLogin(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- ManagerForm managerForm = (ManagerForm) actionForm;
- managerForm.setName(managerForm.getName());
- managerForm.setPwd(managerForm.getPwd());
- int ret = managerDAO.checkManager(managerForm);
- System.out.print("验证结果ret的值:" + ret);
- if (ret == 1) {
- return actionMapping.findForward("managerLoginok");
- } else {
- return actionMapping.findForward("mange rLoginfilse");
- }
- }
- /*
- //查询管理员信息
- private ActionForward managerQuery(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- String str = null;
- servletRequest.setAttribute("managerQuery", managerDAO.query(str));
- return actionMapping.findForward("managerQuery");
- }
- //添加管理员信息
- private ActionForward managerAdd(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- ManagerForm managerForm = (ManagerForm) actionForm;
- managerForm.setName(managerForm.getName());
- managerForm.setPwd(managerForm.getPwd());
- int ret = managerDAO.insert(managerForm);
- if (ret == 1) {
- return actionMapping.findForward("managerAdd");
- } else {
- return actionMapping.findForward("error");
- }
- }
- //查询修改管理员信息
- private ActionForward managerModifyQuery(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse
- servletResponse) {
- ManagerForm managerForm = (ManagerForm) actionForm;
- managerForm.setId(Integer.valueOf(servletRequest.getParameter("id")));
- servletRequest.setAttribute("managerQueryif",
- managerDAO.query_update(managerForm));
- return actionMapping.findForward("managerQueryModify");
- }
- //修改管理员信息
- private ActionForward managerModify(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- ManagerForm managerForm = new ManagerForm();
- managerForm.setName(managerForm.getName());
- managerForm.setPwd(managerForm.getPwd());
- int ret = managerDAO.update(managerForm);
- if (ret == 0) {
- return actionMapping.findForward("error");
- } else {
- return actionMapping.findForward("managerModify");
- }
- }
- //删除管理员信息
- private ActionForward managerDel(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- ManagerForm managerForm = (ManagerForm) actionForm;
- managerForm.setId(Integer.valueOf(servletRequest.getParameter("id")));
- int ret = managerDAO.delete(managerForm);
- if (ret == 0) {
- return actionMapping.findForward("error");
- } else {
- return actionMapping.findForward("managerDel");
- }
- }
- */
- }