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

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.dao.LibraryDAO;
  8. import com.actionForm.LibraryForm;
  9. import org.apache.struts.action.Action;
  10. public class Library extends Action {
  11.     LibraryDAO libraryDAO=null;
  12.     public Library(){
  13.         libraryDAO=new LibraryDAO();
  14.     }
  15.     public ActionForward perform(ActionMapping mapping, ActionForm form,
  16.                                  HttpServletRequest request,
  17.                                  HttpServletResponse response) {
  18.         LibraryForm libraryForm=(LibraryForm) form;
  19.         String str=request.getParameter("action");
  20.         if("libraryQuery".equals(str)){
  21.             return libraryModifyQuery(mapping,form,request,response);
  22.         }else if("libraryModify".equals(str)){
  23.             return libraryModify(mapping,form,request,response);
  24.         }
  25.         request.setAttribute("error","您的操作有误!");
  26.         return mapping.findForward("error");
  27.     }
  28.     private ActionForward libraryModify(ActionMapping mapping, ActionForm form,
  29.                                  HttpServletRequest request,
  30.                                  HttpServletResponse response
  31. ){
  32.         LibraryForm libraryForm = (LibraryForm) form;
  33.         libraryForm.setId(libraryForm.getId());
  34.         libraryForm.setLibraryname(libraryForm.getLibraryname());
  35.         libraryForm.setCurator(libraryForm.getCurator());
  36.         libraryForm.setTel(libraryForm.getTel());
  37.         libraryForm.setAddress(libraryForm.getAddress());
  38.         libraryForm.setEmail(libraryForm.getEmail());
  39.         libraryForm.setUrl(libraryForm.getUrl());
  40.         libraryForm.setCreateDate(libraryForm.getCreateDate());
  41.         libraryForm.setIntroduce(libraryForm.getIntroduce());
  42.         int ret = libraryDAO.update(libraryForm);
  43.         if (ret == 0) {
  44.             request.setAttribute("error", "图书馆信息修改失败!");
  45.             return mapping.findForward("error");
  46.         } else {
  47.             return mapping.findForward("librarymodify");
  48.         }
  49.     }
  50.     private ActionForward libraryModifyQuery(ActionMapping mapping, ActionForm form,
  51.                                  HttpServletRequest request,
  52.                                  HttpServletResponse response
  53. ){
  54.     return mapping.findForward("librarymodify");
  55.     }
  56. }