Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
BookType.java~10~
Package: LibraryManage.rar [view]
Upload User: toby828
Upload Date: 2015-06-26
Package Size: 8558k
Code Size: 5k
Category:
Jsp/Servlet
Development Platform:
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.actionForm.BookTypeForm;
- import org.apache.struts.action.Action;
- import com.dao.BookTypeDAO;
- public class BookType extends Action {
- private BookTypeDAO bookTypeDAO = null;
- public BookType() {
- this.bookTypeDAO = new BookTypeDAO();
- }
- public ActionForward perform(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
- String action =request.getParameter("action");
- System.out.println("nbookType*********************action="+action);
- if(action==null||"".equals(action)){
- request.setAttribute("error","您的操作有误!");
- return mapping.findForward("error");
- }else if("bookTypeAdd".equals(action)){
- return bookTypeAdd(mapping,form,request,response);
- }else if("bookTypeQuery".equals(action)){
- return bookTypeQuery(mapping,form,request,response);
- }else if("bookTypeModifyQuery".equals(action)){
- return bookTypeModifyQuery(mapping,form,request,response);
- }else if("bookTypeModify".equals(action)){
- return bookTypeModify(mapping,form,request,response);
- }else if("bookTypeDel".equals(action)){
- return bookTypeDel(mapping,form,request,response);
- }
- request.setAttribute("error","操作失败!");
- return mapping.findForward("error");
- }
- /***********************添加图书类型信息**************************/
- private ActionForward bookTypeAdd(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- BookTypeForm bookTypeForm = (BookTypeForm) form;
- System.out.println("servlet:"+bookTypeForm.getTypeName());
- bookTypeForm.setTypeName(bookTypeForm.getTypeName());
- int a=bookTypeDAO.insert(bookTypeForm);
- 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("bookTypeAdd");
- }
- }
- /***********************查询全部图书类型信息**************************/
- private ActionForward bookTypeQuery(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- String str=null;
- request.setAttribute("bookType",bookTypeDAO.query(str));
- return mapping.findForward("bookTypeQuery");
- }
- /***********************查询修改图书类型信息**************************/
- private ActionForward bookTypeModifyQuery(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- BookTypeForm bookTypeForm=(BookTypeForm)form;
- bookTypeForm.setId(Integer.valueOf(request.getParameter("ID")));
- request.setAttribute("bookTypeQueryif",bookTypeDAO.queryM(bookTypeForm));
- return mapping.findForward("bookTypeQueryModify");
- }
- /***********************修改图书类型信息**************************/
- private ActionForward bookTypeModify(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- BookTypeForm bookTypeForm=(BookTypeForm)actionForm;
- bookTypeForm.setTypeName(bookTypeForm.getTypeName());
- bookTypeForm.setDays(bookTypeForm.getDays());
- int ret=bookTypeDAO.update(bookTypeForm);
- if(ret==0){
- servletRequest.setAttribute("error","修改图书类型信息失败!");
- return actionMapping.findForward("error");
- }else{
- return actionMapping.findForward("bookTypeModify");
- }
- }
- /***********************删除图书类型信息**************************/
- private ActionForward bookTypeDel(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response){
- BookTypeForm bookTypeForm=(BookTypeForm)actionForm;
- bookTypeForm.setId(Integer.valueOf(servletRequest.getParameter("ID")));
- int ret=bookTypeDAO.delete(bookTypeForm);
- if(ret==0){
- servletRequest.setAttribute("error","删除图书类型信息失败!");
- return actionMapping.findForward("error");
- }else{
- return actionMapping.findForward("bookTypeDel");
- }
- }
- }