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

Jsp/Servlet

开发平台:

Java

  1. package com.action;
  2. import org.apache.struts.action.ActionMapping;
  3. import org.apache.struts.action.ActionForm;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.apache.struts.action.ActionForward;
  7. import com.actionForm.BookCaseForm;
  8. import org.apache.struts.action.Action;
  9. import com.dao.BookCaseDAO;
  10. public class BookCaseAdd extends Action {
  11.     private BookCaseDAO bookCaseDAO=null;
  12.     public BookCaseAdd(){
  13.         this.bookCaseDAO=new BookCaseDAO();
  14.     }
  15.     public ActionForward perform(ActionMapping actionMapping,
  16.                                  ActionForm actionForm,
  17.                                  HttpServletRequest servletRequest,
  18.                                  HttpServletResponse servletResponse) {
  19.         String action =servletRequest.getParameter("action");
  20.     System.out.println("nbookCase*********************action="+action);
  21.     if(action==null||"".equals(action)){
  22.         return actionMapping.findForward("error");
  23.     }else if("bookCaseAdd".equals(action)){
  24.         return bookCaseAdd(actionMapping,actionForm,servletRequest,servletResponse);
  25.     }else if("bookCaseQuery".equals(action)){
  26.         return bookCaseQuery(actionMapping,actionForm,servletRequest,servletResponse);
  27.     }else if("bookCaseModifyQuery".equals(action)){
  28.         return bookCaseModifyQuery(actionMapping,actionForm,servletRequest,servletResponse);
  29.     }else if("bookCaseModify".equals(action)){
  30.         return bookCaseModify(actionMapping,actionForm,servletRequest,servletResponse);
  31.     }else if("bookCaseDel".equals(action)){
  32.         return bookCaseDel(actionMapping,actionForm,servletRequest,servletResponse);
  33.     }
  34.     return actionMapping.findForward("error");
  35.     }
  36.  /***********************添加书架信息**************************/
  37.     private ActionForward bookCaseAdd(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest servletRequest, HttpServletResponse servletResponse){
  38.         BookCaseForm bookCaseForm = (BookCaseForm) actionForm;
  39.         System.out.println("servlet:"+servletRequest.getParameter("name"));
  40.         bookCaseForm.setName(bookCaseForm.getName());
  41.         int a=bookCaseDAO.insert(bookCaseForm);
  42.         if(a==0){
  43.           return actionMapping.findForward("error");
  44.       }else{
  45.           return actionMapping.findForward("bookcaseadd");
  46.      }
  47.     }
  48.     /***********************查询全部书架信息**************************/
  49.     private ActionForward bookCaseQuery(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest servletRequest,HttpServletResponse servletResponse){
  50.     String str=null;
  51.     servletRequest.setAttribute("bookcase",bookCaseDAO.query(str));
  52.     return actionMapping.findForward("bookcaseQuery");
  53.     }
  54.      /***********************查询修改书架信息**************************/
  55.      private ActionForward bookCaseModifyQuery(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest servletRequest,HttpServletResponse servletResponse){
  56.          BookCaseForm bookCaseForm=(BookCaseForm)actionForm;
  57.          bookCaseForm.setId(Integer.valueOf(servletRequest.getParameter("id")));
  58.          servletRequest.setAttribute("bookCaseQueryIf",bookCaseDAO.queryM(bookCaseForm));
  59.          return actionMapping.findForward("bookCaseQueryModify");
  60.      }
  61.      /***********************修改书架信息**************************/
  62.      private ActionForward bookCaseModify(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest servletRequest,HttpServletResponse servletResponse){
  63.          BookCaseForm bookCaseForm=(BookCaseForm)actionForm;
  64.          bookCaseForm.setName(servletRequest.getParameter("name"));
  65.          int ret=bookCaseDAO.update(bookCaseForm);
  66.          if(ret==0){
  67.              return actionMapping.findForward("error");
  68.          }else{
  69.              return actionMapping.findForward("");
  70.          }
  71.      }
  72.      private ActionForward bookCaseDel(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest servletRequest,HttpServletResponse servletResponse){
  73.          BookCaseForm bookCaseForm=(BookCaseForm)actionform;
  74.      }
  75. }