Library.java~21~
上传用户: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.         return mapping.findForward("error");
  26.     }
  27.     private ActionForward libraryModify(ActionMapping mapping, ActionForm form,
  28.                                  HttpServletRequest request,
  29.                                  HttpServletResponse response
  30. ){
  31.         LibraryForm libraryForm = (LibraryForm) form;
  32.         libraryForm.setId(libraryForm.getId());
  33.         libraryForm.setLibraryname(libraryForm.getLibraryname());
  34.         libraryForm.setCurator(libraryForm.getCurator());
  35.         libraryForm.setTel(libraryForm.getTel());
  36.         libraryForm.setAddress(libraryForm.getAddress());
  37.         libraryForm.setEmail(libraryForm.getEmail());
  38.         libraryForm.setUrl(libraryForm.getUrl());
  39.         libraryForm.setCreateDate(libraryForm.getCreateDate());
  40.         libraryForm.setIntroduce(libraryForm.getIntroduce());
  41.         int ret = libraryDAO.update(libraryForm);
  42.         if (ret == 0) {
  43.             request.setAttribute("error", "图书馆信息修改失败!");
  44.             return mapping.findForward("error");
  45.         } else {
  46.             return mapping.findForward("librarymodify");
  47.         }
  48.     }
  49.     private ActionForward libraryModifyQuery(ActionMapping mapping, ActionForm form,
  50.                                  HttpServletRequest request,
  51.                                  HttpServletResponse response
  52. ){
  53.     return mapping.findForward("librarymodify");
  54.     }
  55. }