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.actionForm.BookCaseForm; import org.apache.struts.action.Action; import com.dao.BookCaseDAO; public class BookCase extends Action { private BookCaseDAO bookCaseDAO=null; public BookCase(){ this.bookCaseDAO=new BookCaseDAO(); } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String action =request.getParameter("action"); System.out.println("\nbookCase*********************action="+action); if(action==null||"".equals(action)){ return mapping.findForward("error"); }else if("bookCaseAdd".equals(action)){ return bookCaseAdd(mapping,form,request,response); }else if("bookCaseQuery".equals(action)){ return bookCaseQuery(mapping,form,request,response); }else if("bookCaseModifyQuery".equals(action)){ return bookCaseModifyQuery(mapping,form,request,response); }else if("bookCaseModify".equals(action)){ return bookCaseModify(mapping,form,request,response); }else if("bookCaseDel".equals(action)){ return bookCaseDel(mapping,form,request,response); } request.setAttribute("error","操作失败!"); return mapping.findForward("error"); } /***********************添加书架信息**************************/ private ActionForward bookCaseAdd(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ BookCaseForm bookCaseForm = (BookCaseForm) form; System.out.println("servlet:"+request.getParameter("name")); bookCaseForm.setName(bookCaseForm.getName()); int a=bookCaseDAO.insert(bookCaseForm); if(a==0){ request.setAttribute("error","书架信息添加失败!"); return mapping.findForward("error"); }else if(a==2){ request.setAttribute("error","该书架信息已经添加!"); return mapping.findForward("error"); }else{ return mapping.findForward("bookcaseAdd"); } } /***********************查询全部书架信息**************************/ private ActionForward bookCaseQuery(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ String str=null; request.setAttribute("bookcase",bookCaseDAO.query(str)); return mapping.findForward("bookcaseQuery"); } /***********************查询修改书架信息**************************/ private ActionForward bookCaseModifyQuery(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ BookCaseForm bookCaseForm=(BookCaseForm)form; bookCaseForm.setId(Integer.valueOf(request.getParameter("ID"))); request.setAttribute("bookCaseQueryif",bookCaseDAO.queryM(bookCaseForm)); return mapping.findForward("bookCaseQueryModify"); } /***********************修改书架信息**************************/ private ActionForward bookCaseModify(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){ BookCaseForm bookCaseForm=(BookCaseForm)form; bookCaseForm.setName(request.getParameter("name")); int ret=bookCaseDAO.update(bookCaseForm); if(ret==0){ request.setAttribute("error","修改书架信息失败!"); return mapping.findForward("error"); }else{ return mapping.findForward("bookCaseModify"); } } /***********************删除书架信息**************************/ private ActionForward bookCaseDel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ){ BookCaseForm bookCaseForm=(BookCaseForm)form; bookCaseForm.setId(Integer.valueOf(request.getParameter("ID"))); int ret=bookCaseDAO.delete(bookCaseForm); if(ret==0){ request.setAttribute("error","删除书架信息失败!"); return mapping.findForward("error"); }else{ return mapping.findForward("bookCaseDel"); } } }
最近下载更多
卑微大学生在线学java LV1
6月30日
柳咪华沙 LV7
6月28日
RAINK_L LV3
2023年12月12日
hfkdny LV2
2023年6月6日
dmyafda LV5
2023年3月26日
想飞的大肥猪 LV9
2023年3月10日
微信网友_5925912300212224 LV1
2023年1月29日
微信网友_6254095067451392 LV3
2022年12月9日
askjhfasf LV1
2022年11月5日
ARTICLE LV3
2022年10月28日
最近浏览更多
xiao peppa
11月10日
暂无贡献等级
微信网友_7225075969921024
10月25日
暂无贡献等级
252537406
10月25日
暂无贡献等级
1220261962d
10月15日
暂无贡献等级
krispeng LV13
10月2日
微信网友_7161495321989120 LV1
9月10日
dsczs666
8月18日
暂无贡献等级
暂无贡献等级
54ty1212
8月6日
暂无贡献等级
小小小小白
7月15日
暂无贡献等级