




已阅读5页,还剩16页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
请完成某公司的教材管理系统教材基本信息管理模块的设计任务,具体功能如下。用户键入http:/localhost:8080/bookXXX/servlet/queryBookAction (其中XXX为考生学号后三位)即列出如下信息(可以无表格,无表头):教材号书名编者价格ISBN1035Java张三1650978-7-666修改删除修改删除修改删除1039C语言李四1800978-7-668修改删除单击“修改”可以转向教材修改页面,列出所选教材所有信息供修改(可无表格)。教材号1039书名C语言编者李四ISBN978-7-669价格19.00提交单击“提交”按钮,可以将修改后的信息保存到数据库表中。保存成功后,立即转发回查询页面。例如:教材号书名编者价格ISBN1035Java张三1650978-7-666修改删除修改删除修改删除1039C语言李四1900978-7-669修改删除数据库设计:源程序web.xml This is the description of my J2EE component This is the display name of my J2EE component QueryBookAction com.action.QueryBookAction This is the description of my J2EE component This is the display name of my J2EE component EditBookPrepare com.action.EditBookPrepare This is the description of my J2EE component This is the display name of my J2EE component EditBookAction com.action.EditBookAction This is the description of my J2EE component This is the display name of my J2EE component DeleteBookAction com.action.DeleteBookAction QueryBookAction /servlet/queryBookAction EditBookPrepare /servlet/EditBookPrepare EditBookAction /servlet/EditBookAction DeleteBookAction /servlet/DeleteBookAction index.jsp /罗涛,信管082,,2008021327package com.daomain;public class Book private Long id ;private String bNo;private String bName;private String editor;private String price;private String isbn;public Book() super();/ TODO Auto-generated constructor stubpublic Book(Long id, String no, String name, String editor, String price,String isbn) super();this.id = id;bNo = no;bName = name;this.editor = editor;this.price = price;this.isbn = isbn;public Long getId() return id;public void setId(Long id) this.id = id;public String getBNo() return bNo;public void setBNo(String no) bNo = no;public String getBName() return bName;public void setBName(String name) bName = name;public String getEditor() return editor;public void setEditor(String editor) this.editor = editor;public String getPrice() return price;public void setPrice(String price) this.price = price;public String getIsbn() return isbn;public void setIsbn(String isbn) this.isbn = isbn; /罗涛,2008021327package com.dao;import java.util.List;import com.daomain.Book;public interface BoookDao Book findById (Long id)throws Exception;List findAll()throws Exception;void save(Book book) throws Exception;void update(Book book) throws Exception;void delete(Long id ) throws Exception;package com.dao;/ 罗涛,信管082,2008021327import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;import java.util.List;import com.daomain.Book;import com.util.DbUtil;public class BookDaoImpl implements BoookDao private DbUtil DbUtil = new DbUtil();public void delete(Long id) throws Exception / TODO Auto-generated method stubConnection conn = DbUtil.getConnection();Statement stmt =conn.createStatement();stmt.executeUpdate(delete from book where id =+id);public List findAll() throws Exception / TODO Auto-generated method stubList BookList = new ArrayList ();Connection conn = DbUtil.getConnection();Statement stmt = conn.createStatement();ResultSet rs = stmt.executeQuery(select * from Book);Book Book =null;while(rs.next()Book= queryBook(rs);BookList.add(Book);return BookList;public Book findById(Long id) throws Exception / TODO Auto-generated method stubConnection conn = DbUtil.getConnection();Statement stmt = conn.createStatement(); ResultSet rs=stmt.executeQuery(select * from book where id =+id); Book book= null; if (rs.next() book =queryBook(rs);return book;public void save(Book book) throws Exception / TODO Auto-generated method stubpublic void update(Book book) throws Exception / TODO Auto-generated method stubConnection conn = DbUtil.getConnection(); PreparedStatement pstmt = conn.prepareStatement( update book +set bNo=?,bName=?,editor=?,price=?,isbn=? where id=? ); pstmt.setString(1,book.getBNo(); pstmt.setString(2,book.getBName(); pstmt.setString(3,book.getEditor(); pstmt.setString(4,book.getPrice(); pstmt.setString(5,book.getIsbn(); pstmt.setLong(6, book.getId(); pstmt.executeUpdate();private Book queryBook( ResultSet rs)throws SQLException Long id= rs.getLong(id);String bNo= rs.getString(bNo);String bName =rs.getString(bName);String editor = rs.getString(editor);String price = rs.getString(price);String isbn = rs.getString(isbn);Book Book = new Book(id,bNo,bName,editor,price,isbn);return Book;package com.action;/罗涛信管082 2008021327import java.io.IOException;import java.io.PrintWriter;import java.util.List;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.dao.BookDaoImpl;import com.daomain.Book;public class QueryBookAction extends HttpServlet /罗涛,2008021327/* * Constructor of the object. */public QueryBookAction() super();/* * Destruction of the servlet. */public void destroy() super.destroy(); / Just puts destroy string in log/ Put your code here/* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request, response);/* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException response.setContentType(text/html);response.setCharacterEncoding(UTF-8);PrintWriter out= response.getWriter();BookDaoImpl bookDao= new BookDaoImpl();RequestDispatcher rd =null;try List bookList =bookDao.findAll();request.setAttribute(bookList, bookList);System.out.println(bookList);rd=request.getRequestDispatcher(./pages/queryBook.jsp); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();rd.forward(request, response);/* * Initialization of the servlet. * * throws ServletException if an error occurs */public void init() throws ServletException / Put your code here/罗涛,2008021327package com.action;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.dao.BookDaoImpl;import com.daomain.Book;public class EditBookPrepare extends HttpServlet /* * Constructor of the object. */public EditBookPrepare() super();/* * Destruction of the servlet. */public void destroy() super.destroy(); / Just puts destroy string in log/ Put your code here/* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request, response);/* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException response.setContentType(text/html);response.setCharacterEncoding(UTF-8);String id_Str =request.getParameter(id);Long id_Long = Long.parseLong(id_Str);BookDaoImpl bookDao = new BookDaoImpl();RequestDispatcher rd =null;try Book book = bookDao.findById(id_Long);request.setAttribute(book, book);rd= request.getRequestDispatcher(./pages/editBook.jsp); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();rd.forward(request, response);/* * Initialization of the servlet. * * throws ServletException if an error occurs */public void init() throws ServletException / Put your code herepackage com.action;/罗涛,2008021327import java.io.IOException;import java.io.PrintWriter;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.dao.BookDaoImpl;import com.daomain.Book;public class EditBookAction extends HttpServlet /* * Constructor of the object. */public EditBookAction() super();/* * Destruction of the servlet. */public void destroy() super.destroy(); / Just puts destroy string in log/ Put your code here/* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request, response);/* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException request.setCharacterEncoding(UTF-8);response.setCharacterEncoding(UTF-8);String id_Str =request.getParameter(id);Long id =Long.parseLong(id_Str);String bNo= request.getParameter(bNo);String bName= request.getParameter(bName);String editor = request.getParameter(editor);String price = request.getParameter(price);String isbn =request.getParameter(isbn);Book book = new Book(id,bNo,bName,editor,price,isbn);BookDaoImpl bookDao = new BookDaoImpl();RequestDispatcher rd =null;try bookDao.update(book);rd= request.getRequestDispatcher(./servlet/queryBookAction); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();rd.forward(request,response);/* * Initialization of the servlet. * * throws ServletException if an error occurs */public void init() throws ServletException / Put your code herepackage com.action;/罗涛,2008021327import java.io.IOException;import java.io.PrintWriter;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.dao.BookDaoImpl;public class DeleteBookAction extends HttpServlet /* * Constructor of the object. */public DeleteBookAction() super();/* * Destruction of the servlet. */public void destroy() super.destroy(); / Just puts destroy string in log/ Put your code here/* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request, response);/* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String id_Str = request.getParameter(id);Long id_Long = Long.parseLong(id_Str);BookDaoImpl bookDao = new BookDaoImpl();RequestDispatcher rd =null;try bookDao.delete(id_Long);rd= request.getRequestDispatcher(./servlet/queryBookAction); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();rd.forward(request, response);/* * Initialization of the servlet. * * throws ServletException if an error occurs */public void init() throws ServletException / Put your code herepackage com.util;/罗涛,2008021327import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;public c
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 食品批发商知识应用能力提升方案分析报告
- 油乳制备工技术考核试卷及答案
- 青浦净化彩钢板施工方案
- 小区建筑方案设计费
- 城市文化品牌发展模式研究分析报告
- 中铁项目部临建施工方案
- 和平家园建筑方案设计理念
- 幼儿园公益营销方案策划
- 线下品鉴活动方案策划
- 青海企业咨询管理方案
- 《进一步规范管理燃煤自备电厂工作方案》发改体改〔2021〕1624号
- 学生手册超级题库
- 现金收付业务管理办法
- 《多元统计分析-基于R(第3版)》课件全套 费宇 第1-13章-多元统计分析与R简介-多维标度分析
- 法学论文开题报告模板范文
- 2024年山东省高考物理试卷(真题+答案)
- 人音版小学六年级上册音乐教案 全册
- 2024年国家义务教育质量监测体育与健康学科成绩提升培训会
- 单侧双通道UBE手术
- 装饰图案-从图案到设计作业
- 【川教版】《生命 生态 安全》二年级上册第3课 我的鸡蛋宝宝 课件
评论
0/150
提交评论