javaWeb书店管理系统.docx
- 文档编号:7773403
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:26
- 大小:22.64KB
javaWeb书店管理系统.docx
《javaWeb书店管理系统.docx》由会员分享,可在线阅读,更多相关《javaWeb书店管理系统.docx(26页珍藏版)》请在冰豆网上搜索。
javaWeb书店管理系统
一、实验目的
1)理解并掌握编码与测试相关理论与方法;
2)进一步熟悉利用编程语言实现系统;
3)要求学生理解测试在软件开发中的重要地位;
4)学生了解测试用例与测试报告的相关书写规范。
二、实验内容与要求
1)根据系统的特点,选取javaWebMVC开发模型实现该系统;
2)系统的编码结构:
边界类:
1个html(项目首页),13个jsp(中间跳转的页面),一个css(界面美化功能),一个javascript(控制输入合法性)。
控制类:
一个servlet类(连接边界类和实体类)
实体类:
一个datebase类(连接数据库),一个bookinfo类(书本的增删检查操作)
服务器采用tomcat。
如下图展示:
3)对系统进行测试分析,并对系统功能实施测试,编写测试用例,系统已经实现可以让
手机电脑一起访问并做操作;
4)撰写实验报告,同时需要了解测试报告相应的规范与写法。
1.下面是一些界面的展示(没有全部展示):
登录页面
顾客首页
购买页面
订单页面
查询页面
查询结果
管理员页面添加图书页面
添加图书信息不完整页面
三、完整开发代码(按照上面截图部署即可实现)
Table.css:
body{
background:
#ffffff;margin:
15;
}
body,table,th,td,input,select,textarea{
font-family:
Tahoma,Verdana,Arial,Helvetica,sans-serif;font-size:
12px;
}
table.default{
border:
1pxsolid#3366CC;
border-collapse:
collapse;
width:
80%;
}
table.defaulttd{
padding:
2525;
height:
26px;
text-align:
center;
border:
1pxsolid#ffffff;
background-color:
#f0f0f0;
}
table.defaulttr.titletd{font-weight:
bold;text-align:
center;
background:
#99CCFF;
color:
red;
border:
1pxsolid#ffffff;
white-space:
nowrap;
height:
26px;
}
table.defaultth.item{
font-weight:
bold;
color:
#333333;
text-align:
center;
vertical-align:
top;
padding:
10px;
font-size:
14px;
}
xyh.css:
body{font-family:
Arial,Helvetica,sans-serif;font-size:
12px;color:
#666666;background:
#fff;text-align:
center;}
*{margin:
0;padding:
0;}
a{color:
#1E7ACE;text-decoration:
none;}a:
hover{color:
#000;text-decoration:
underline;}h3{font-size:
14px;font-weight:
bold;}pre,p{color:
#1E7ACE;margin:
4px;}input,select,textarea{padding:
1px;
margin:
2px;font-size:
11px;}
.buttom{padding:
1px10px;font-size:
12px;border:
1px#1E7ACEsolid;background:
#D0F0FF;}
#formwrapper{width:
450px;margin:
15pxauto;padding:
20px;text-align:
left;border:
1pxsolid#A4CDF2;}fieldset{padding:
10px;margin-top:
5px;
border:
1pxsolid#A4CDF2;background:
#fff;}
fieldsetlegend{color:
#1E7ACE;font-weight:
bold;padding:
3px20px3px20px;border:
1pxsolid#A4CDF2;background:
#fff;}
fieldsetlabel{float:
left;width:
120px;text-align:
right;padding:
4px;margin:
1px;}fieldsetdiv{clear:
left;margin-bottom:
2px;}.input{width:
120px;}
.enter{text-align:
center;}
.clear{clear:
both;}
Common.js:
functionisNum(num){
for(i=0;i { c=num.charAt(i); if(c>'9'||c<'0'){ returnfalse; } } returntrue; } functioncheck(){ {alert("noid! "); returnfalse;} {alert("noname! "); returnfalse;} { alert("noauthor! "); returnfalse; } { alert("nopress! "); returnfalse; } alert("nodate! ") returnfalse; } if(! isNum(form1.price)){alert("priceiswrong! ")returnfalse; } if(! isNum(form1.account)){alert("accountiswring! ")returnfalse; } Bookinfo.java: packagebean; publicclassbookinfo{ privateStringid; privateStringname; privateStringauthor; privateStringpress; privateStringdate; privateintprice; privateintaccount; publicvoidsetName(Stringname){this.name=name; } publicStringgetName(){ returnname; } publicvoidsetAuthor(Stringauthor){this.author=author; } publicStringgetAuthor(){ returnauthor; } publicvoidsetDate(Stringdate){this.date=date; } publicStringgetDate(){ returndate; } publicvoidsetPress(Stringpress){this.press=press; } publicStringgetPress(){ returnpress; } publicvoidsetId(Stringid){this.id=id; } publicStringgetId(){ returnid; } publicvoidsetAccount(intacount){this.account=acount; } publicintgetAccount(){ returnaccount; } publicvoidsetPrice(intprice){ this.price=price; } publicintgetPrice(){ returnprice; } publicstaticArrayList while(rs.next()){bookinfobi=newbookinfo();bi.setId(rs.getString("id"));bi.setName(rs.getString("name"));bi.setAuthor(rs.getString("author"));bi.setPress(rs.getString("press"));bi.setDate(rs.getString("date"));bi.setPrice(rs.getInt("price"));bi.setAccount(rs.getInt("account"));list.add(bi); } rs.close(); } catch(SQLExceptione){ e.printStackTrace(); } jdbc.close(); returnlist; } //通过编号书名作者来搜索 publicstaticArrayList Stringsql=null; intway=0; if(! id.equals("")){way=way+1;} if(! name.equals("")){way=way+10;} if(! author.equals("")){way=way+100;} if(way==1||way==11||way==101){sql="select*frombook.bookshopwhereid='"+id+"'"; } if(way==10){sql="select*frombook.bookshopwherenamelike'%"+name+"%'"; } if(way==100){sql="select*frombookshopwhereauthorlike'%"+author+"%'"; } if(way==110){sql="select*frombookshopwherenamelike'%"+name+"%'andauthorlike'%"+author+"%'"; } dbbeanjdbc=newdbbean(); ResultSetrs=jdbc.executeQuery(sql); try{while(rs.next()){bookinfobi=newbookinfo();bi.setDate(rs.getString("date"));bi.setPress(rs.getString("press"));bi.setAuthor(rs.getString("author"));bi.setName(rs.getString("name"));bi.setId(rs.getString("id"));bi.setPrice(rs.getInt("price"));bi.setAccount(rs.getInt("account"));list.add(bi); }rs.close(); } catch(SQLExceptione){ } jdbc.close(); returnlist; } publicstaticbookinfogetbookbyid(Stringid){ Stringsql="select*frombook.bookshopwhereid='"+id+"'"; dbbeanjdbc=newdbbean(); ResultSetrs=jdbc.executeQuery(sql); bookinfobi=newbookinfo(); try{ if(rs.next()){bi.setDate(rs.getString("date"));bi.setPress(rs.getString("press")); bi.setAuthor(rs.getString("author")); bi.setName(rs.getString("name"));bi.setId(rs.getString("id"));bi.setPrice(rs.getInt("price")); bi.setAccount(rs.getInt("account")); } rs.close(); } catch(SQLExceptione){ } jdbc.close(); returnbi; } publicstaticintupdatebook(Stringid,Stringname,Stringauthor,Stringpress,Stringdate,intprice,intaccount){ intresult=0; Stringsql="updatebook.bookshopsetname='"+name+"',author='"+author+"',press='"+press+"',date='"+date+"',price="+price+",account="+account+"whereid='"+id+"'"; dbbeanjdbc=newdbbean(); result=jdbc.executeUpdate(sql); returnresult; } publicstaticintdeletebook(Stringid){ intresult=0; Stringsql="deletefrombook.bookshopwhereid='"+id+"'"; dbbeanjdbc=newdbbean(); result=jdbc.executeUpdate(sql); returnresult; } publicstaticintaddbook(Stringid,Stringname,Stringauthor,Stringpress,Stringdate,intprice,intaccount){ intresult=0; Stringsql="insertintobook.bookshop(id,name,author,press,date,price,account)values('"+id+"','"+name+"','"+author+"','"+press+"','"+date+"',"+price+","+account+")"; dbbeanjdbc=newdbbean();result=jdbc.executeUpdate(sql); returnresult; } } } Dbbean.java: packagebean; importjava.lang.*; importjava.sql.*;publicclassdbbean{ privateStringname="root"; privateStringpassword="xyh201268"; privateConnectionconn=null; privateStatementstmt=null; publicdbbean(){ try{ Class.forName(driverStr); conn=DriverManager.getConnection(connStr,name,password); stmt=conn.createStatement(); } catch(Exceptionex){ } } publicintexecuteUpdate(Strings){ intresult=0; try{ result=stmt.executeUpdate(s); } catch(Exceptionex){ } returnresult; } publicResultSetexecuteQuery(Strings){ ResultSetrs=null; try{rs=stmt.executeQuery(s); } catch(Exceptionex){ }returnrs; }publicvoidclose(){try{stmt.close();conn.close(); } catch(Exceptionex){ } } } Servlet.java: packageservlets;importjava.lang.*; *CreatedbyAdministratoron14-5-31.*/ publicclassServletextendsHttpServlet{ protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{ doPost(request,response); } protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{ request.setCharacterEncoding("utf-8"); Stringaction=request.getServletPath();if(action.equals("/servlets/depend.do")){ Stringvalue=request.getParameter("password");if(value.equals("123")){ request.setAttribute("list",list);request.getRequestDispatcher("/manager.jsp").forward(request,response); }else request.setAttribute("list",list);request.getRequestDispatcher("/reader.jsp").forward(request,response); } } elseif(action.equals("/servlets/list_m.do")){request.setAttribute("list",list);request.getRequestDispatcher("/manager.jsp").forward(request,response); } elseif(action.equals("/servlets/list_r.do")){request.setAttribute("list",list);request.getRequestDispatcher("/reader.jsp").forward(request,response); } elseif(action.equals("/servlets/edit.do")){Stringid=request.getParameter("id");request.setAttribute("bi",bi);request.getRequestDispatcher("/edit.jsp").forward(request,response); } elseif(action.equals("/servlets/update.do")){Stringid=request.getParameter("id");Stringname=request.getParameter("name");Stringauthor=request.getParameter("author");Stringpress=request.getParameter("press");Stringdate=request.getParameter("date");Strings_price=request.getParameter("price");Strings_account=request.getParameter("account");intprice=Integer.parseInt(s_price);intaccount=Integer.parseInt(s_account);if(r==1){request.getRequestDispatcher("/success_m.jsp").forward(request,response); }else{request.getRequestDispatcher("/failure_m.jsp").forward(request,response); } elseif(action.equals("/servlets/delete.do")){ Stringid=request.getParameter("id"); if(r==1){request.getRequestDispatcher("/success_m.jsp").forward(request,response); } else{request.getRequestDispatcher("/failure_m.jsp").forward(request,response); } } elseif(action.equals("/servlets/add.do")){ Stringid=request.getParameter("id"); Stringname=request.getParameter("name"); Stringauthor=request.getPara
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- javaWeb 书店 管理 系统