Library.java
资源名称:Library.rar [点击查看]
上传用户:ycdfsj258
上传日期:2022-08-04
资源大小:1094k
文件大小:3k
源码类别:
图形图象
开发平台:
Java
- package com.action;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionForm;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForward;
- import com.dao.LibraryDAO;
- import com.actionForm.LibraryForm;
- import org.apache.struts.action.Action;
- public class Library extends Action {
- LibraryDAO libraryDAO=null;
- public Library(){
- libraryDAO=new LibraryDAO();
- }
- public ActionForward perform(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
- LibraryForm libraryForm=(LibraryForm) form;
- String str=request.getParameter("action");
- if("libraryQuery".equals(str)){
- return libraryModifyQuery(mapping,form,request,response);
- }else if("libraryModify".equals(str)){
- return libraryModify(mapping,form,request,response);
- }
- request.setAttribute("error","您的操作有误!");
- return mapping.findForward("error");
- }
- private ActionForward libraryModify(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response
- ){
- LibraryForm libraryForm = (LibraryForm) form;
- libraryForm.setId(libraryForm.getId());
- libraryForm.setLibraryname(libraryForm.getLibraryname());
- libraryForm.setCurator(libraryForm.getCurator());
- libraryForm.setTel(libraryForm.getTel());
- libraryForm.setAddress(libraryForm.getAddress());
- libraryForm.setEmail(libraryForm.getEmail());
- libraryForm.setUrl(libraryForm.getUrl());
- libraryForm.setCreateDate(libraryForm.getCreateDate());
- libraryForm.setIntroduce(libraryForm.getIntroduce());
- int ret = libraryDAO.update(libraryForm);
- if (ret ==0) {
- request.setAttribute("error", "图书馆信息修改失败!");
- return mapping.findForward("error");
- } else {
- return mapping.findForward("librarymodify");
- }
- }
- private ActionForward libraryModifyQuery(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response
- ){
- request.setAttribute("libraryModifyif",libraryDAO.query());
- return mapping.findForward("librarymodifyQuery");
- }
- }