Java Web实验程序设计——图书借阅网站的实现——图书信息

预 习 报 告

实验题目:图书借阅网站的实现——图书信息

预习内容:

  1. Servlet的概述

Servlet 是使用Java 语言编写的运行在服务器端的程序。狭义的 Servlet 是指Java 语言实现的一个接口,广义的Servlet是指任何实现了这个Servlet接口的类,一般情况下,人们将Servlet理解为后者。Servlet 主要用于处理客户端传来的 HTTP 请求,并返回一个响应,它能够处理的请求有 doGet()和doPost()等方法。

  1. JSP的特征

⑴跨平台性 ⑵业务代码相分离性 ⑶组件重用性 ⑷预编译性

  1. JavaBean的概述

JavaBean 是 Java 开发语言中一个可以重复使用的软件组件,它本质上就是一个Java类。

  1. JDBC常用的API的介绍

JDBC API主要位于java.sql包中,该包定义了一系列访问数据库的接口和类。

  1. MVC的模型

模型(Model)负责管理应用程序的业务数据、定义访问控制以及修改这些数据的业务规则。当模型的状态发生改变时,它会通知视图发生改变,并为视图提供查询模型状态的方法。

  1. DAO的概述

DAO(Data Access Object)数据访问对象是一个面向对象的数据库接口

实验目的与要求(及主要实验仪器、设备):

1、掌握Servlet的基本特性、生命周期和编程方式;

2、掌握JSP的基本特性和编程方式;

3、掌握JavaBean的基本特性和编程方式;;

4、掌握MVC和DAO设计模式的编程特性;

5、使用MVC和DAO设计模式设计图书借阅网站中图书信息的功能。

本次实验采用的主要设备:自带电脑。

实验原理(方法与与原理分析):

  1. navigation.jsp 管理员导航条界面
  2. banner.jsp: 头部界面
  3. copyright.jsp: 版权界面   
  4. booktype.java  图书类型实体类
  5. bookinfo.java  图书信息实体类
  6. booktype_queryall.jsp 图书类型设置界面
  7. booktype_add.jsp 图书类型添加界面
  8. booktype_update.jsp 图书类型修改界面
  9. bookInfo_queryall.jsp  图书信息设置界面
  10. bookInfo_add.jsp  图书信息添加界面
  11. bookInfo_update.jsp  图书信息修改界面
  12. BookTypeAdd Servlet.java 图书类型添加功能控制器类
  13. BookInfoAdd Servlet.java 图书信息添加功能控制器类
  14. BookTypeQueryAllServlet.java 图书类型功能控制器类
  15. BookInfoQueryAllServlet.java 图书信息功能控制器类
  16. BookTypeUpdateServlet.java  图书类型修改功能控制器类
  17. BookInfoUpdateServlet.java  图书信息修改功能控制器类
  18. BookTypeDeleteServlet.java  图书类型删除功能控制器类
  19. BookInfoDeleteServlet.java  图书信息删除功能控制器类
  20. BookTypeDAO.java  图书类型功能接口类
  21. bookInfoDAO.java  图书信息功能接口类
  22. bookInfoDAOImpl.java:图书信息功能实现类
  23. bookTypeDAOImpl.java:图书类型功能实现类
  24. DAOFactory.java 工厂类
  25. DBConnection.java:数据库连接类
  26. web.xml 配置文件

实验步骤(程序代码与实验过程):

1.BookInfo.java
package vo;
public class BookInfo {
int bookid;
String bookname;
int booktypeid;
	String author;
	String pubname;
	String isbn;
	double price;
	String casename;
	int nownumber;
	int total;
	String booktypename;
	public int getBookid() {
		return bookid;
	}
	public void setBookid(int bookid) {
		this.bookid = bookid;
	}
	public String getBookname() {
		return bookname;
	}
	public void setBookname(String bookname) {
		this.bookname = bookname;
	}
	public int getBooktypeid() {
		return booktypeid;
	}
	public void setBooktypeid(int booktypeid) {
		this.booktypeid = booktypeid;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getPubname() {
		return pubname;
	}
	public void setPubname(String pubname) {
		this.pubname = pubname;
	}
	public String getIsbn() {
		return isbn;
	}
	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public String getCasename() {
		return casename;
	}
	public void setCasename(String casename) {
		this.casename = casename;
	}
	public int getNownumber() {
		return nownumber;
	}
	public void setNownumber(int nownumber) {
		this.nownumber = nownumber;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public String getBooktypename() {
		return booktypename;
	}
	public void setBooktypename(String booktypename) {
		this.booktypename = booktypename;
	}	
}
2.booktype.java
private   int booktypeid;
private   String  booktypename;
public int getBooktypeid() {
return booktypeid;
}
public void setBooktypeid(int booktypeid) {
this.booktypeid = booktypeid;
}
public String getBooktypename() {
return booktypename;
}
public void setBooktypename(String booktypename) {
this.booktypename = booktypename;
}
3.bookinfo_add.jsp
<body>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书管理 &gt; 图书管理 &gt; 添加图书信息 &gt;&gt;&gt;</td>
</tr>
<tr>
<td align="center" valign="top"><table width="100%" height="493"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookInfoAddServlet">
<table width="600" height="432"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="center">图书编号:</td>
<td height="39"><input name="bookid" type="text" id="bookid" size="50">
* </td>
</tr>
<tr>
<td align="center">图书名称:</td>
<td height="39"><input name="bookname" type="text" id="bookname" size="50">
* </td>
</tr>
<tr>
<td align="center">图书类型:</td>
<td>
<select name="booktypeid" class="wenbenkuang" id="booktypeid">
<%
List<BookType> list=(List<BookType>)session.getAttribute("allbooktype");
for(int i=0;i<list.size();i++){
BookType booktype=list.get(i);
%>
<option value="<%=booktype.getBooktypeid()%>"><%=booktype.getBooktypename()%></option>
<%}%>
</select>
</td>
</tr>
<tr>
<td align="center">作者:</td>
<td><input name="author" type="text"  id="author" size="40"></td>
</tr>   
<tr>
<td align="center">出版社:</td>
<td>
<select name="pubname" class="wenbenkuang" id="pubname">    
<option value="清华大学出版社">清华大学出版社</option>
<option value="人民邮电出版社">人民邮电出版社</option>
<option value="北京大学出版社">北京大学出版社</option>
<option value="北京理工出版社">北京理工出版社</option>        
</select> 
</td>
</tr>
<tr>
<td align="center">ISBN:</td>
<td><input name="isbn" type="text" id="isbn"> * </td>
</tr>
<tr>
<td align="center">价格:</td>
<td><input name="price" type="text" id="price">(元) * </td>
</tr>
<tr>
<td align="center">书架:</td>
<td>
<select name="casename" class="wenbenkuang" id="casename">              
<option value="TP">TP</option>
<option value="CM">CM</option>
<option value="CM">IO</option>                    
</select>
</tr>
<tr>
<td align="center">现存量:</td>
<td><input name="nownumber" type="text" id="nownumber">(本) * </td>
</tr>
<tr>
<td align="center">库存量:</td>
<td><input name="total" type="text" id="total">(本) * </td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td><input name="Submit" type="submit" class="btn_grey" value="保存" onClick="return check(form1)">
&nbsp;
<input name="Submit2" type="button" class="btn_grey" value="返回" onClick="history.back()"></td>
</tr>
</table>
</form>
</td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table><%@ include file="copyright.jsp"%></td>
</tr>
</table>
</body>
4.bookinfo_update.jsp
<body>
<%@include file="banner.jsp"%>
<%@include file="navigation.jsp"%> 
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书管理 &gt; 图书管理 &gt; 修改图书信息 &gt;&gt;&gt;</td>
</tr>
<tr>
<td align="center" valign="top"><table width="100%" height="493"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookInfoUpdateServlet">
<table width="600" height="432"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="center">图书名称:
<input name="bookid" type="hidden" size="50" value="<%=request.getParameter("bookid")%>">
</td>
<td height="39">
<input name="bookname" type="text"  id="bookname"  size="60" value="<%=new String(java.net.URLDecoder.decode(request.getParameter("bookname"),"GB18030").getBytes("ISO-8859-1"))%>"> 
</td>
</tr>
<tr>
<td align="center">图书类型:</td>
<td><select name="booktypeid"  >
<%
List<BookType> allbooktype=(List<BookType>)request.getSession().getAttribute("allbooktype");
String booktypename=new String(java.net.URLDecoder.decode(request.getParameter("booktypename"),"GB18030").getBytes("ISO-8859-1"));
int booktypeid=Integer.parseInt(request.getParameter("booktypeid"));
for(int i=0;i<allbooktype.size();i++){
BookType booktype=allbooktype.get(i);
if(booktypeid==booktype.getBooktypeid()){
%>
<option value="<%=booktypeid%>" selected="selected"><%=booktype.getBooktypename()%></option>
<% 
}else{
%>
<option value="<%=booktype.getBooktypeid()%>"><%=booktype.getBooktypename()%></option>
<%}%>
<%}%>
</select>
</td>
</tr>
<tr>
<td align="center">作者:</td>
<td><input name="author" type="text"  id="author" size="40"  value="<%=new String(java.net.URLDecoder.decode(request.getParameter("author"),"GB18030").getBytes("ISO-8859-1"))%>"></td>
</tr>
<tr>
<td align="center">出版社:</td>
<td>
<select name="pubname" class="wenbenkuang">
<option value="清华大学出版社">清华大学出版社</option>               <option value="人民邮电出版社">人民邮电出版社</option>               <option value="北京大学出版社">北京大学出版社</option>                <option value="北京理工出版社">北京理工出版社</option>                </select>          
</td>      
</tr>       
<tr>
<td align="center">ISBN:</td>
<td><input name="isbn" type="text" id="isbn" value="<%=new String(java.net.URLDecoder.decode(request.getParameter("isbn"),"GB18030").getBytes("ISO-8859-1"))%>">  </td>
</tr>            
<tr>        
<td align="center">价格:</td>        
<td><input name="price"type="text"id="price"value="<%=request.getParameter("price")%>">(元) * </td>
</tr>       
<tr>        
<td align="center">现存量:</td>        
<td><input name="nownumber" type="text" id="nownumber"  value="<%=request.getParameter("nownumber")%>">(本) * </td>      
</tr>      
<tr>        
<td align="center">库存量:</td>        
<td><input name="total" type="text" id="total" value="<%=request.getParameter("bookid")%>">(本) * </td>      
</tr>      
<tr>        
<td align="center">书架:</td>
<td><select name="casename" class="wenbenkuang" id="casename" >                 <option value="TP">TP</option>                 
<option value="CM">CM</option>                 
<option value="CM">IO</option>                
</select>       
</td>      
</tr>      
<tr>        
<td align="center">&nbsp;</td>        
<td><input name="Submit" type="submit" class="btn_grey" value="保存" onClick="return check(form1)">        
&nbsp;       
<input name="Submit2" type="button" class="btn_grey" value="返回" onClick="history.back()"></td>      
</tr>    
</table>	</form>	</td>  
</tr></table></td>      
</tr>    
</table></td>  
</tr></table><%@ include file="copyright.jsp"%></td>  
</tr></table>  
</body>
5.bookinfo_delete.jsp
<body>   
<%@include file="banner.jsp"%>   
<%@include file="navigation.jsp"%>   
<%  bookinfo bookinfo=(bookinfo)session.getAttribute("bookinfo");        %>  <table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">  <tr>    
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">  
<tr>    
<td height="510" valign="top" style="padding:5px;"><table width="98%" height="487"  border="0" cellpadding="0" cellspacing="0">      
<tr>        
<td height="22" valign="top" class="word_orange">当前位置:图书管理 &gt; 图书管理 &gt; 修改图书信息 &gt;&gt;&gt;</td>      
</tr>      
<tr>         
<td align="center" valign="top">
<table width="100%" height="493"  border="0" cellpadding="0" cellspacing="0">  
<tr>    
<td align="center" valign="top">	
<form name="form1" method="post" action="BookInfoUpdateServlet">	
<table width="600" height="432"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">      
<tr>        
<td align="center">图书名称:           
<input name="bookid" type="hidden" size="50" value="<%=bookinfo.getBookid()%>">        
</td>        
<td height="39">          
<input name="bookname" type="text"  id="bookname"  size="60" value="<%=bookinfo.getBookname()%>" readonly>*         
</td>      
</tr>      
<tr>        
<td align="center">图书类型:
</td>        
<td>        	
<select name="booktypename" id="booktypename" >	 	              
<option value="
<%=bookinfo.getBooktypename()%>">
<%=bookinfo.getBooktypename()%>
</option>	              	              	              
<% List
<booktype> allbooktype=(List
<booktype>)session.getAttribute("allbooktype"); 			
for(int i=0;i
<allbooktype.size();i++){				booktype booktype=allbooktype.get(i);%>	          
<option value="
<%=booktype.getBooktypename()%>">
<%=booktype.getBooktypename()%>
</option>		
<%} %>			
</select>        
</td>      
</tr>      
<tr>        
<td align="center">作者:
</td>        
<td>
<input name="author" type="text"  id="author" size="40"  value="
<%=bookinfo.getAuthor()%>">
</td>      
</tr>      
<tr>        
<td align="center">出版社:
</td>        
<td>        
<select name="pubname" class="wenbenkuang">              
<option value="清华大学出版社">清华大学出版社
</option>               
<option value="人民邮电出版社">人民邮电出版社
</option>               
<option value="北京大学出版社">北京大学出版社
</option>                
<option value="北京理工出版社">北京理工出版社
</option>                
</select>          
</td>      
</tr>       
<tr>        
<td align="center">ISBN:
</td>        
<td>
<input name="isbn" type="text" id="isbn" value="
<%=bookinfo.getIsbn()%>">  
</td>      
</tr>            
<tr>        
<td align="center">价格:
</td>        
<td>
<input name="price" type="text" id="price" value="
<%=bookinfo.getPrice()%>">(元) * 
</td>      
</tr>       
<tr>        
<td align="center">现存量:
</td>        
<td>
<input name="nownumber" type="text" id="nownumber"  value="
<%=bookinfo.getNownumber()%>">(本) * 
</td>      
</tr>      
<tr>        
<td align="center">库存量:
</td>        
<td>
<input name="total" type="text" id="total"  value="
<%=bookinfo.getTotal()%>">(本) * 
</td>      
</tr>      
<tr>        
<td align="center">书架:
</td>        
<td>
<select name="casename" class="wenbenkuang" id="casename" >                 
<option value="TP"                 
<%if("TP".equals(bookinfo.getCasename())){%>selected
<%}%>>TP
</option>                 
<option value="CM"                 
<%if("CM".equals(bookinfo.getCasename())){%>selected
<%}%>>CM
</option>                 
<option value="IO"                 
<%if("IO".equals(bookinfo.getCasename())){%>selected
<%}%>>IO
</option>                
</select>                  
</td>      
</tr>        
<tr>        
<td align="center">&nbsp;
</td>        
<td>
<input name="Submit" type="submit" class="btn_grey" value="保存" onClick="return check(form1)">        &nbsp;       
<input name="Submit2" type="button" class="btn_grey" value="返回" onClick="history.back()">
</td>      
</tr>    
</table>	
</form>	
</td>  
</tr>
</table>
</td>      
</tr>    
</table>
</td>  
</tr>
</table>
<%@ include file="copyright.jsp"%>
</td>  
</tr>
</table>  
</body>
6.Bookinfo_queryall.jsp
<%@include file="banner.jsp" %>
<%@include file="navigation.jsp" %>
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="385" valign="top" bgcolor="#FFFFFF"><table width="99%" height="341"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="341" valign="top" style="padding:5px;"><table width="98%" height="295"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:系统设置 &gt; 图书设置 &gt;&gt;&gt;</td>
</tr>
<tr>
<td height="273" align="center" valign="top">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="BookInfoTypeQueryAllServleta" >添加图书信息</a> </td>
</tr>
</table>
<table width="100%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#F6B83B" bordercolorlight="#FFFFFF">
<tr align="center" bgcolor="#e3F4F7">
<td width="5%"    bgcolor="#F9D16B" >图书编号</td>
<td width="10%" bgcolor="#F9D16B">图书名称</td>
<td width="10%" bgcolor="#F9D16B">图书类型</td>
<td width="10%" bgcolor="#F9D16B">作者</td>
<td width="10%" bgcolor="#F9D16B">出版社</td>
<td width="10%" bgcolor="#F9D16B">ISBN</td>
<td width="10%" bgcolor="#F9D16B">价格</td>
<td width="5%" bgcolor="#F9D16B">书架</td>
<td width="10%" bgcolor="#F9D16B" >现存量</td>
<td width="10%" bgcolor="#F9D16B">总库存</td>
<td width="5%" bgcolor="#F9D16B">修改</td>
<td width="5%" bgcolor="#F9D16B">删除</td>
</tr>
<%List list=(List)request.getSession().getAttribute("allbookinfo");
for(int i=0;i<list.size();i++){
BookInfo bookinfo = (BookInfo)list.get(i);%> 
<tr>
<td style="padding:5px;"><%=bookinfo.getBookid()%></td>
<td style="padding:5px;"><%= bookinfo.getBookname()%></td>
<td style="padding:5px;"><%=bookinfo.getBooktypename()%></td>
<td style="padding:5px;"><%=bookinfo.getAuthor()%></td>
<td style="padding:5px;"><%=bookinfo.getPubname()%></td>
<td style="padding:5px;"><%=bookinfo.getIsbn()%></td>
<td style="padding:5px;"><%=bookinfo.getPrice()%></td>
<td style="padding:5px;"><%=bookinfo.getCasename()%></td>
<td style="padding:5px;"><%=bookinfo.getNownumber()%></td>
<td style="padding:5px;"><%=bookinfo.getTotal()%></td>
<td align="center"><a href="BookInfoTypeQueryAllServlet?bookid=<%=bookinfo.getBookid()%>&bookname=<%=URLEncoder.encode(bookinfo.getBookname(),"gb18030")%>&booktypename=<%=URLEncoder.encode(bookinfo.getBooktypename(),"gb18030")%>&author=<%=URLEncoder.encode(bookinfo.getAuthor(),"gb18030")%>&pubname=<%=URLEncoder.encode(bookinfo.getPubname(),"gb18030")%>&isbn=<%=URLEncoder.encode(bookinfo.getIsbn(),"gb18030")%>&casename=<%=URLEncoder.encode(bookinfo.getCasename(),"gb18030")%>&price=<%=bookinfo.getPrice()%>&nownumber=<%=bookinfo.getNownumber()%>&total=<%=bookinfo.getTotal()%>&booktypeid=<%=bookinfo.getBooktypeid()%>">修改</a></td>
<td align="center"><a href="BookInfoDeleteServlet?bookid=<%=bookinfo.getBookid()%>" >删除</a></td> 
</tr>
<%}%>  
</table>
</td>
</tr>
</table>
</td>
</tr>
</table><%@ include file="copyright.jsp"%></td>
</tr>
7.booktype_add.jsp
<table width="292" height="175" border="0" cellpadding="0" cellspacing="0" background="Images/subBG.jpg">
<tr>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="3%" height="25">&nbsp;</td>
<td width="94%">&nbsp;</td>
<td width="3%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><table width="100%" height="131"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="BookTypeAddServlet">
<table width="100%" height="114"  border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="74" align="center">图书类型编号:
<input name="booktypeid" type="text"><br>
图书类型名称:
<input name="booktypename" type="text"></td>
</tr>
<tr>
<td align="center" style="width: 177px; "><input name="Submit3" type="submit" class="btn_grey" value="保存">
&nbsp;
<input name="Submit22" type="button" class="btn_grey" value="关闭" onClick="window.close();"></td>

8.booktype_update.jsp
<form name="form1" method="post" action="BookTypeUpdateServlet">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="50" align="center">  图书类型名称:
<%    List<booktype> updatebooktype=new ArrayList<booktype>();
updatebooktype=(List<booktype>)session.getAttribute("updatebooktype"); 
for(int i=0;i<updatebooktype.size();i++){
booktype  booktype=updatebooktype.get(i);	
%>  <input name="booktypeid" type="hidden" value="<%=booktype.getBooktypeid() %>">
<input name="booktypename" type="text" value="<%=booktype.getBooktypename() %>"/>
<%
} %>     
</td> 
</tr>
<tr>
<td height="35" align="center"><input name="Submit" type="submit" class="btn_grey" value="保存">
&nbsp;
<input name="Submit2" type="reset" class="btn_grey" value="重置">
&nbsp;
<input name="Submit3" type="button" class="btn_grey" onClick="window.close()" value="关闭"></td>
</tr>
</table>
</form>
9.booktype_queryall.jsp
<body>     
<%@include file="banner.jsp" %>     
<%@include file="navigation.jsp" %>     
<table width="778"  border="0" cellspacing="0" cellpadding="0" align="center">      
<tr>         
<td height="385" valign="top" bgcolor="#FFFFFF">
<table width="99%" height="341"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">       
<tr>         
<td height="341" valign="top" style="padding:5px;">
<table width="98%" height="295"  border="0" cellpadding="0" cellspacing="0">      
<tr>          
<td height="22" valign="top" class="word_orange">当前位置:图书管理信息 &gt; 图书类型设置 &gt;&gt;&gt;
</td>      
</tr>      
<tr>        
<td height="273" align="center" valign="top">          
<table width="100%"  border="0" cellspacing="0" cellpadding="0">            
<tr>           
<td>
<a href="booktype_add.jsp" >添加图书类型信息
</a> 
</td>                   
</tr>          
</table>   
<table width="91%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#F6B83B" bordercolorlight="#FFFFFF">  
<tr align="center" bgcolor="#e3F4F7">    
<td width="30%" bgcolor="#F9D16B">图书类型编号
</td>    
<td width="40%" bgcolor="#F9D16B">图书类型名称
</td>    
<td width="16%" bgcolor="#F9D16B">修改
</td>    
<td width="14%" bgcolor="#F9D16B">删除
</td>  
</tr>
<!-- 取值显示 allBookType(List) 会话  for——BookType——booktypeid  booktypename -->
<%    List
<booktype> allbooktype = (List
<booktype>) session.getAttribute("allbooktype");    for(int i=0;i
<allbooktype.size();i++){    booktype booktype=allbooktype.get(i); %>  
<tr>   
<td style="padding:5px;">
<%=booktype.getBooktypeid()%>
</td>   
<!-- 显示 -->    
<td style="padding:5px;">
<%=booktype.getBooktypename()%>
</td>    
<td align="center">
<a href="BookTypeSearchServlet?booktypeid=
<%=booktype.getBooktypeid()%>">修改
</a>
</td>    
<td align="center">
<a href="BookTypeDeleteServlet?booktypeid=
<%=booktype.getBooktypeid()%>">删除
</a>
</td>   
</tr>
<%} %> 
</table>
</td>      
</tr>    
</table>
</td>  
</tr>
</table>
<%@ include file="copyright.jsp"%>
</td>  
</tr>
</table>  
</body>
10.BookTypeAddServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContenttype("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
booktype booktype=new booktype();
booktype.setBooktypeid(Integer.parseInt(request.getParameter("booktypeid")));
booktype.setBooktypename(request.getParameter("booktypename"));
try {
if(DAOFactory.getBooktypeDAOInstance().doCreate(booktype)){
request.getRequestDispatcher("BooktypeQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
11.BookTypeUpdteServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
String booktypename = request.getParameter("booktypename");
int booktypeid = Integer.parseInt(request.getParameter("booktypeid"));
booktype booktype=new booktype();
booktype.setBooktypeid(booktypeid);
booktype.setBooktypename(booktypename);
try {
if(DAOFactory.getBookTypeDAOInstance().doUpdate(booktype)){
request.getRequestDispatcher("BookTypeQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}}

12.BookTypeDeleteServlet.java
throws ServletException, IOException {
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");
int booktypeid=Integer.parseInt(request.getParameter("booktypeid"));
try {
if(DAOFactory.getBookTypeDAOInstance().doDelete(booktypeid)){
request.getRequestDispatcher("BookTypeQueryAllServlet").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
}
}
13.BookTypeQueryAllServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb18030");
response.setContentType("text/html;charset=gb18030");
try {
List<booktype> allbooktype=DAOFactory.getBookTypeDAOInstance().findAllbooktype();
request.getSession().setAttribute("allbooktype", allbooktype);
request.getRequestDispatcher("booktype_queryall.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
14.BookInfoAddServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");		
booktype_add.jsp booktypeid booktypename,		        
bookinfo bookinfo=new bookinfo();		        bookinfo.setBookid(Integer.parseInt(request.getParameter("bookid")));		        bookinfo.setBookname(request.getParameter("bookname"));		        bookinfo.setBooktypename(request.getParameter("booktypename"));		        bookinfo.setAuthor(request.getParameter("author"));		        bookinfo.setPubname(request.getParameter("pubname"));		        bookinfo.setIsbn(request.getParameter("isbn"));		        bookinfo.setPrice(Double.parseDouble(request.getParameter("price")));		        bookinfo.setCasename(request.getParameter("casename"));		        bookinfo.setNownumber(Integer.parseInt(request.getParameter("nownumber")));		        bookinfo.setTotal(Integer.parseInt(request.getParameter("total")));								
try {					
if(DAOFactory.getBookInfoDAOInstance().doCreate(bookinfo)){								
request.getRequestDispatcher("BookInfoQueryAllServlet").forward(request, response);					
}				
} catch (Exception e) {			e.printStackTrace();				}			}
this.doGet(request, response);
15.BookInfoUpdteServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");		//取值	设置vo		bookinfo bookinfo=new bookinfo();        bookinfo.setBookid(Integer.parseInt(request.getParameter("bookid")));        bookinfo.setBookname(request.getParameter("bookname"));        bookinfo.setBooktypename(request.getParameter("booktypename"));        //bookinfo.setBooktypeid(Integer.parseInt(request.getParameter("booktypename")));        bookinfo.setAuthor(request.getParameter("author"));        bookinfo.setPubname(request.getParameter("pubname"));        bookinfo.setIsbn(request.getParameter("isbn"));        bookinfo.setPrice(Double.parseDouble(request.getParameter("price")));        bookinfo.setCasename(request.getParameter("casename"));        bookinfo.setNownumber(Integer.parseInt(request.getParameter("nownumber")));        bookinfo.setTotal(Integer.parseInt(request.getParameter("total")));				
try {					
if(DAOFactory.getBookInfoDAOInstance().doUpdate(bookinfo)){
request.getRequestDispatcher("BookInfoQueryAllServlet").forward(request, response);					
}				
} catch (Exception e) {					
e.printStackTrace();				
}	}
8.BookInfoDeleteServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");		int bookid=Integer.parseInt(request.getParameter("bookid"));		
try {			
if(DAOFactory.getBookInfoDAOInstance().doDelete(bookid))
{				
request.getRequestDispatcher("BookInfoQueryAllServlet").forward(request, response);			
}		
} catch (Exception e)
{
e.printStackTrace();		
}			
}
16.BookInfoQueryAllServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{		
response.setContentType("text/html;charset=gb18030");
request.setCharacterEncoding("gb18030");		
try {			
List<bookinfo> allbookinfo=DAOFactory.getBookInfoDAOInstance().findAllbookinfo();		
request.getSession().setAttribute("allbookinfo", allbookinfo);		
List<booktype> allbooktype=DAOFactory.getBookTypeDAOInstance().findAllbooktype();		
request.getSession().setAttribute("allbooktype", allbooktype);				
request.getRequestDispatcher("bookinfo_queryall.jsp").forward(request, response);	
} catch (Exception e) 
{			
// TODO Auto-generated catch block			
e.printStackTrace();		
}	
}
17.Web.xml
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoAddServlet</servlet-name>
<servlet-class>servlet.BookInfoAddServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoQueryAllServlet</servlet-name>
<servlet-class>servlet.BookInfoQueryAllServlet</servlet-class>
</servlet>
<servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoDeleteServlet</servlet-name>
<servlet-class>servlet.BookInfoDeleteServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookInfoUpdateServlet</servlet-name>
<servlet-class>servlet.BookInfoUpdateServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeAddServlet</servlet-name>
<servlet-class>servlet.BookTypeAddServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeQueryAllServlet</servlet-name>
<servlet-class>servlet.BookTypeQueryAllServlet</servlet-class>
</servlet>
<servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeDeleteServlet</servlet-name>
<servlet-class>servlet.BookTypeDeleteServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>BookTypeUpdateServlet</servlet-name>
<servlet-class>servlet.BookTypeUpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookInfoAddServlet</servlet-name>
<url-pattern>/BookInfoAddServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookInfoQueryAllServlet</servlet-name>
<url-pattern>/BookInfoQueryAllServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookInfoDeleteServlet</servlet-name>
<url-pattern>/BookInfoDeleteServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookInfoUpdateServlet</servlet-name>
<url-pattern>/BookInfoUpdateServlet</url-pattern>
 </servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeAddServlet</servlet-name>
<url-pattern>/BookTypeAddServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeQueryAllServlet</servlet-name>
<url-pattern>/BookTypeQueryAllServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeDeleteServlet</servlet-name>
<url-pattern>/BookTypeDeleteServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BookTypeUpdateServlet</servlet-name>
<url-pattern>/BookTypeUpdateServlet</url-pattern>
 </servlet-mapping>
18.BookTypeDAO.java
public  List<booktype> findAllbooktype() throws  Exception;
public boolean  doCreate(booktype  booktype)throws  Exception;
public boolean  doDelete(int  booktypeid)throws  Exception; 
public boolean doUpdate(booktype booktype)throws Exception;
List<booktype> findupdate(int booktypeid) throws Exception;
19.BookInfoDAO.java
public  List<bookinfo> findAllbookinfo() throws  Exception;
public boolean  doCreate(bookinfo  bookinfo)throws  Exception;
public boolean doDelete(int bookid) throws Exception;
public boolean doUpdate(bookinfo bookinfo) throws Exception;
public bookinfo findbookinfo(int bookid) throws Exception;
20.BookTypeDAOImpl.java
public List<booktype> findAllbooktype() throws Exception {
List<booktype> allbooktype=new ArrayList<booktype>();
try{
String sql="select * from booktype";
conn=dbc.getConnection();
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next()){
booktype booktype=new booktype();
booktype.setBooktypeid(rs.getInt("booktypeid"));
booktype.setBooktypename(rs.getString("booktypename"));
allbooktype.add(booktype);
}
rs.close();
pstmt.close();
}
catch(Exception e){e.printStackTrace();}
finally{dbc.closed();
}
return allbooktype;
}
@Override
public boolean doCreate(booktype booktype) throws Exception {
try{
String sql="insert into booktype values(?,?)";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1, booktype.getBooktypeid());
pstmt.setString(2, booktype.getBooktypename());
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}catch(Exception e){e.printStackTrace();}
finally{
dbc.closed();
}	
return flag;
}
@Override
public boolean doDelete(int booktypeid) throws Exception {
try{
String sql="delete  from booktype where booktypeid=?";
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1,booktypeid);
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}catch(Exception e){}
finally{
dbc.closed();
}
return flag;
}
@Override
public List<booktype> findupdate(int booktypeid) throws Exception {
List<booktype> updatebooktype=new ArrayList<booktype>();
try{
String sql="select booktypeid,booktypename from booktype where booktypeid=?";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, booktypeid);
rs=pstmt.executeQuery();
while(rs.next()){
booktype booktype=new booktype();
booktype.setBooktypeid(rs.getInt("booktypeid"));
booktype.setBooktypename(rs.getString("booktypename"));
updatebooktype.add(booktype);
}
pstmt.close();
}catch(Exception e){
e.printStackTrace();
}finally{
dbc.closed();
}
return updatebooktype;
}
@Override
public boolean doUpdate(booktype booktype) throws Exception {
try{
String sql="update booktype set booktypename=? where booktypeid=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,booktype.getBooktypename());
pstmt.setInt(2, booktype.getBooktypeid());
int i=pstmt.executeUpdate();
if(i>0){
flag=true;
}
pstmt.close();
}
catch(Exception e){e.printStackTrace();}
finally{
dbc.closed();
}
return flag;
}
}
21.BookInfoDAOImpl.java
public class BookInfoDAOImpl implements BookInfoDAO
{	private PreparedStatement pstmt=null;	
private ResultSet rs=null;	
boolean flag=false;	
DBConnection dbc=new DBConnection();	
Connection conn=dbc.getConnection();	
@Override	public List<bookinfo> findAllbookinfo() throws  
Exception{	List<bookinfo> allbookinfo=new ArrayList<bookinfo>();				
try{			
String sql="select bookid,bookname,booktypename,author,pubname,isbn,price,casename,nownumber,total from bookinfo join booktype on bookinfo.booktypeid=booktype.booktypeid";			
//conn=dbc.getConnection();			
pstmt=conn.prepareStatement(sql);			
rs=pstmt.executeQuery();			
while(rs.next()){				
bookinfo bookinfo=new bookinfo();				
bookinfo.setBookid(rs.getInt("bookid"));				
bookinfo.setBookname(rs.getString("bookname"));				
bookinfo.setBooktypename(rs.getString("booktypename"));				
bookinfo.setAuthor(rs.getString("author"));			
bookinfo.setPubname(rs.getString("pubname"));				
bookinfo.setIsbn(rs.getString("isbn"));				
bookinfo.setPrice(rs.getDouble("price"));				
bookinfo.setCasename(rs.getString("casename"));				
bookinfo.setNownumber(rs.getInt("nownumber"));				
bookinfo.setTotal(rs.getInt("total"));				allbookinfo.add(bookinfo);			}			
rs.close();			
pstmt.close();			
}		    
catch(Exception e){e.printStackTrace();}		
finally{dbc.closed();			
}		
return allbookinfo;	
}	@Override	
public boolean doCreate(bookinfo  
bookinfo)throws  
Exception {		
// TODO Auto-generated method stub		
try{			
String sql="insert into bookinfo values(?,?,(select  booktypeid  from booktype where  booktypename=?),?,?,?,?,?,?,?)";			
pstmt=conn.prepareStatement(sql);			
pstmt.setInt(1, bookinfo.getBookid());			
pstmt.setString(2,bookinfo.getBookname());			
pstmt.setString(3,bookinfo.getBooktypename());			
pstmt.setString(4,bookinfo.getAuthor());			
pstmt.setString(5,bookinfo.getPubname());			
pstmt.setString(6,bookinfo.getIsbn());			
pstmt.setDouble(7,bookinfo.getPrice());			
pstmt.setString(8,bookinfo.getCasename());			
pstmt.setInt(9,bookinfo.getNownumber());			
pstmt.setInt(10,bookinfo.getTotal());			
int i=pstmt.executeUpdate();			
if(i>0){				
flag=true;			
}			
pstmt.close();		
}catch(Exception e)
{e.printStackTrace();}		
finally{			
dbc.closed();		
}			
return flag;	
}	@Override	public boolean doDelete(int bookid) throws Exception 
{		
// TODO Auto-generated method stub		
try {			
String sql="delete from bookinfo where bookid=?";			
pstmt=conn.prepareStatement(sql);			
pstmt.setInt(1, bookid);			
int i=pstmt.executeUpdate();			
if(i>0){				
flag=true;			
}			
pstmt.close();		
} catch (Exception e) {
e.printStackTrace();		
} finally{			
dbc.closed();
}		
return flag;	
}	@Override	
public boolean doUpdate(bookinfo bookinfo) throws Exception 
{		
// TODO Auto-generated method stub		
try {			
String sql="update bookinfo set bookname=?,booktypeid=(select booktypeid from booktype where booktypename=?),author=?,pubname=?,isbn=?,price=?,casename=?,nownumber=?,total=?  where bookid=?";			pstmt=conn.prepareStatement(sql);			
pstmt.setString(1,bookinfo.getBookname());			
pstmt.setString(2,bookinfo.getBooktypename());			
pstmt.setString(3,bookinfo.getAuthor());			
pstmt.setString(4,bookinfo.getPubname());			
pstmt.setString(5,bookinfo.getIsbn());			
pstmt.setDouble(6,bookinfo.getPrice());			
pstmt.setString(7,bookinfo.getCasename());			
pstmt.setInt(8,bookinfo.getNownumber());			
pstmt.setInt(9,bookinfo.getTotal());			
pstmt.setInt(10,bookinfo.getBookid());			
int i=pstmt.executeUpdate();			
if(i>0){				
flag=true;			
}			
pstmt.close();		
} 
catch (Exception e) {
e.printStackTrace();		
} finally{
dbc.closed();		
}			
return flag;	
}	@Override	
public bookinfo findbookinfo(int bookid)  throws Exception
{				
bookinfo bookinfo = new bookinfo();		
try {			
bookid,bookname,bookinfo.booktypeid,booktypename,author,pubname,isbn,price,casename,nownumber,total from bookinfo join booktype on bookinfo.booktypeid=booktype.booktypeid";			
String sql="select bookinfo.*,booktype.* from bookinfo join booktype on bookinfo.booktypeid=booktype.booktypeid where bookid=?";			
pstmt=conn.prepareStatement(sql);			
pstmt.setInt(1, bookid);			
rs=pstmt.executeQuery();			
while(rs.next()){				
bookinfo.setBookid(rs.getInt("bookid"));				
bookinfo.setBookname(rs.getString("bookname"));				
bookinfo.setBooktypename(rs.getString("booktypename"));				
bookinfo.setAuthor(rs.getString("author"));				
bookinfo.setPubname(rs.getString("pubname"));				
bookinfo.setIsbn(rs.getString("isbn"));				
bookinfo.setPrice(rs.getFloat("price"));				
bookinfo.setCasename(rs.getString("casename"));				
bookinfo.setNownumber(rs.getInt("nownumber"));				
bookinfo.setTotal(rs.getInt("total"));			
}			
pstmt.close();			
rs.close();		
} catch (Exception e) {			
e.printStackTrace();		
} finally{			
dbc.closed();		
}				
return bookinfo;	
}
22.DAOFactory.java
public static UsersDAO getUsersDAOInstance(){
return new UsersDAOImpl();
}
public static BookTypeDAO getBookTypeDAOInstance(){
return new BookTypeDAOImpl();
}
public static BookInfoDAO getBookInfoDAOInstance(){
return new BookInfoDAOImpl();
}

实验结果(数据分析与结论):

1.查看图书信息

2.添加图书信息

3.查看添加后的图书信息

4.修改图书信息

5.查看修改后的图书信息

6.查看删除后的图书信息

7.查看图书类型

8.添加图书类型

9.查看添加后的图书类型信息

10.修改图书类型信息

11.查看修改后的图书类型信息

11.查看删除后的图书类型信息

问题讨论:

1.问:出现NullPointException错误

答:

1.主要是因为使用请求转发的时候要获取一个还没有设置的会话造成的

2.由此我把跳转方式换为了重定向跳转,继而成功执行

2.问:出现严重: Parse error in application web.xml file at jndi:/localhost/BMSProject009/WEB-INF/web.xml 错误

答:经排查发现问题原因在web.xml里<servlet>里的<servlet-name>与<servlet-mapping>里的<servlet-name>名称不对称,经其修改后执行成功。

3.问:出现严重: Error getConfigured错误

答:

1.经过排查发现这个错误是出现于web.xml里;

2.出现原因是在创建与jsp文件相对应的servlet文件时有一个文件删除并创建时与web.xml不对应;

3.这个问题的解决方法为找到出现问题的servlet文件删除,然后在web.xml把对应的servlet的信息删除,最后重建对应的servlet文件,问题就解决了。

  1. 图书信息查看功能的实现

在主页点击图书设置得到图书设置界面,通过menu.JS界面的<a href=”BookInfoQueryAllServlet”>跳转到BookInfoQueryAllServlet,获取表单信息设置会话,通过工厂类DAOFctory中静态方法getBookinfoDAOInstance(),得到BookInfoDAOImpl实现类的对象,通过BookInfoDAO接口来执行数据库中的操作,然后使用vo中findAllbookinfo(),通过DBConnection,执行SQL语句,跳转到bookinfo_queryall.jsp,将查询到的图书信息显示出来。

  1. 图书信息添加功能的实现

在图书设置界面点击添加图书信息,通过bookinfo_queryall.jsp里的<a href="bookinfo_add.jsp" >语句,跳转到bookinfo_add.jsp,添加信息后通过<form>表单的action属性,跳转到BookInfoAddServlet控制器,在BookInfoAddServlet中使用 request 请求对象的 getParameter()方法获取表单bookid,author,booktypeid,bookname,casename,isbn,nownumber,price,pubname,total对应的信息的信息,设置vo后,执行BookInfoDAOImpl实现类的方法doCreate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookInfoQueryAllServlet,使用 List 方法获取图书信息,在设置会话跟踪后跳转到 bookinfo_queryall.jsp,最后展现出添加后的图书信息。

  1. 图书信息修改功能的实现

在图书设置界面点击修改,通过bookinfo_queryall.jsp里的href语句,跳转到BookInfoSearchServlet,在BookInfoSearchServlet中使用 request 请求对象的 getParameter()方法获取表单中bookid对应的信息,跳转到bookinfo_update.jsp,修改完成信息后通过<form>表单的action属性,跳转到BookInfoUpdateServlet控制器,BookInfoUpdateServlet中使用 request 请求对象的 getParameter()方法获取表单中使用 request 请求对象的 getParameter()方法获取表单bookid,author,booktypeid,bookname,casename,isbn,nownumber,price,pubname,total对应的信息的,设置vo后,执行BookInfoDAOImpl实现类的方法findupdate和doUpdate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookInfoQueryAllServlet,使用 List 方法获取图书信息,在设置会话跟踪后跳转到 bookinfo_queryall.jsp,最后展现出修改后的图书信息。

  1. 图书信息删除功能的实现

在图书设置界面点击删除,通过bookinfo_queryall.jsp里的href语句,跳转到BookInfoDeleteServlet,在BookInfoDeleteServlet中使用 request 请求对象的 getParameter()方法获取表单中bookid对应的信息,执行BookInfoDAOImpl实现类的方法doDelete,通过DBConnection,执行SQL语句,使用get()方法跳转到BookInfoQueryAllServlet,使用 List 方法获取图书信息,在设置会话跟踪后跳转到bookinfo_queryall.jsp,最后展现出删除后的图书信息。

  1. 图书类型查看功能的实现

在主页点击图书设置得到图书类型设置界面,通过menu.JS界面的<a href=”BookTypeQueryAllServlet”>跳转到BookTypeQueryAllServlet,获取表单信息设置会话,通过工厂类DAOFctory中静态方法getBooktypeDAOInstance(),得到BookTypeDAOImpl实现类的对象,通过BookTypeDAO接口来执行数据库中的操作,然后使用vo中findAllbooktype(),通过DBConnection,执行SQL语句,跳转到booktype_queryall.jsp,将查询到的图书类型信息显示出来。

  1. 图书类型添加功能的实现.

在图书类型设置界面点击添加图书类型,通过booktype_queryall.jsp里的<a href="booktype_add.jsp" >语句,跳转到booktype_add.jsp,添加信息后通过<form>表单的action属性,跳转到BookTypeAddServlet控制器,在BookTypeAddServlet中使用 request 请求对象的 getParameter()方法获取表单中booktypeid,booktypename对应的信息的信息,设置vo后,执行BookTypeDAOImpl实现类的方法doCreate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookTypeQueryAllServlet,使用 List 方法获取图书类型信息,在设置会话跟踪后跳转到 booktype_queryall.jsp,最后展现出添加后的图书类型信息。

  1. 图书类型修改功能的实现

在图书类型设置界面点击修改,通过booktype_queryall.jsp里的href语句,跳转到BookTypeSearchServlet,在BookTypeSearchServlet中使用 request 请求对象的 getParameter()方法获取表单中booktypeid对应的信息,跳转到booktype_update.jsp,修改完成信息后通过<form>表单的action属性,跳转到BookTypeUpdateServlet控制器,在BookTypeUpdateServlet中使用 request 请求对象的 getParameter()方法获取表单中使用 request 请求对象的 getParameter()方法获取表单中booktypeid,booktypename对应的信息的,设置vo后,执行BookTypeDAOImpl实现类的方法findupdate和doUpdate,通过DBConnection,执行SQL语句,使用get()方法跳转到BookTypeQueryAllServlet,使用 List 方法获取图书类型信息,在设置会话跟踪后跳转到 booktype_queryall.jsp,最后展现出修改后的图书类型信息。

  1. 图书类型删除功能的实现

在图书类型设置界面点击删除,通过booktype_queryall.jsp里的href语句,跳转到BookTypeDeleteServlet,在BookTypeDeleteServlet中使用 request 请求对象的 getParameter()方法获取表单中booktypeid对应的信息,执行BookTypeDAOImpl实现类的方法doDelete,通过DBConnection,执行SQL语句,使用get()方法跳转到BookTypeQueryAllServlet,使用 List 方法获取图书类型信息,在设置会话跟踪后跳转到 booktype_queryall.jsp,最后展现出删除后的图书类型信息。

  • 3
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

轩辕椿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值