javaWeb書店管理系統(tǒng)_第1頁
javaWeb書店管理系統(tǒng)_第2頁
javaWeb書店管理系統(tǒng)_第3頁
javaWeb書店管理系統(tǒng)_第4頁
javaWeb書店管理系統(tǒng)_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、一、實(shí)驗(yàn)?zāi)康睦斫獠⒄莆站幋a與測試相關(guān)理論與方法;進(jìn)一步熟悉利用編程語言實(shí)現(xiàn)系統(tǒng);要求學(xué)生理解測試在軟件開發(fā)中的重要地位;學(xué)生了解測試用例與測試報(bào)告的相關(guān)書寫規(guī)范。二、實(shí)驗(yàn)內(nèi)容與要求根據(jù)系統(tǒng)的特點(diǎn),選取javaWeb MVC 開發(fā)模型實(shí)現(xiàn)該系統(tǒng);系統(tǒng)的編碼結(jié)構(gòu):邊界類:1個(gè)html (項(xiàng)目首頁),13個(gè)jsp (中間跳轉(zhuǎn)的頁面),一個(gè)css (界面美化功能),一個(gè)javascript (控制輸入合法性)??刂祁悾阂粋€(gè)servlet 類(連接邊界類和實(shí)體類)實(shí)體類:一個(gè)datebase 類(連接數(shù)據(jù)庫),一個(gè)bookinfo 類(書本的增刪檢查操作)服務(wù)器采用 tomcat 。如下圖展示:對(duì)系統(tǒng)進(jìn)

2、行測試分析,并對(duì)系統(tǒng)功能實(shí)施測試,編寫測試用例,系統(tǒng)已經(jīng)實(shí)現(xiàn)可以讓手機(jī)電腦一起訪問并做操作;撰寫實(shí)驗(yàn)報(bào)告,同時(shí)需要了解測試報(bào)告相應(yīng)的規(guī)范與寫法。下面是一些界面的 展示 (沒有全部展示):登錄頁面顧客首頁購買頁面訂單頁面 查詢頁面 查詢結(jié)果 管理員頁面添加圖書頁面 添加圖書信息不完整頁面三、完整開發(fā)代碼(按照上面截圖部署即可實(shí)現(xiàn))Table.css:bodybackground: #ffffff;margin: 15;body,table,th,td,input,select,textareafont-family: Tahoma,Verdana,Arial,Helvetica,sans-ser

3、if;font-size: 12px;table.defaultborder: 1px solid #3366CC;border-collapse: collapse;width: 80%;table.default tdpadding: 2 5 2 5;height: 26px;text-align: center;border: 1px solid #ffffff;background-color: #f0f0f0;table.default tr.title tdfont-weight: bold;text-align: center;background: #99CCFF;color:

4、 red;border: 1px solid #ffffff;white-space: nowrap;height: 26px;table.default th.itemfont-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:ce

5、nter;* 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;.buttompadding:1px 10px;font-size:12px;border:1px #1E7ACE solid;

6、background:#D0F0FF;#formwrapper width:450px;margin:15px auto;padding:20px;text-align:left;border:1px solid #A4CDF2; fieldset padding:10px;margin-top:5px;border:1px solid #A4CDF2;background:#fff;fieldset legend color:#1E7ACE;font-weight:bold;padding:3px 20px 3px 20px;border:1px solid #A4CDF2;backgrou

7、nd:#fff;fieldset label float:left;width:120px;text-align:right;padding:4px;margin:1px;fieldset div clear:left;margin-bottom:2px;.input width:120px;.enter text-align:center;.clear clear:both;Common.js:function isNum(num)for(i=0;i9|c0)return false;return true;function check()alert (no id!);return fals

8、e;alert(no name!);return false;alert(no author!);return false;alert(no press!); return false;alert(no date!) return false;if(!isNum(form1.price) alert(price is wrong!) return false;if(!isNum(form1.account) alert(account is wring!) return false;Bookinfo.java:package bean;public class bookinfoprivate

9、String id;private String name;private String author;private String press;private String date;private int price;private int account;public void setName(String name) = name;public String getName() return name;public void setAuthor(String author) this.author = author;public String getAuthor() return au

10、thor;public void setDate(String date) this.date = date;public String getDate() return date;public void setPress(String press) this.press = press;public String getPress() return press;public void setId(String id) this.id = id;public String getId() return id;public void setAccount(int acount) this.acc

11、ount = acount;public int getAccount() return account;public void setPrice(int price) this.price = price;public int getPrice() return price;public static ArrayList getbooklist() ArrayList list=new ArrayList(); String sql=select * from book.bookshop;dbbean jdbc=new dbbean();ResultSet rs=jdbc.executeQu

12、ery(sql);trywhile(rs.next()bookinfo bi=new bookinfo();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(S

13、QLException e) e.printStackTrace();jdbc.close();return list;/通過編號(hào)書名 作者來搜索public static ArrayList getbookbyway(String id,String name,String author) ArrayList list=new ArrayList();String sql=null;int way=0;if (!id.equals()way=way+1;if (!name.equals()way=way+10;if (!author.equals()way=way+100;if (way=1

14、|way=11|way=101)sql=select * from book.bookshop where id=+id+;if (way=10)sql=select * from book.bookshop where name like %+name+%;if (way=100)sql=select * from bookshop where author like %+author+%;if (way=110)sql=select * from bookshop where name like %+name+% and author like %+author+%;dbbean jdbc

15、=new dbbean();ResultSet rs=jdbc.executeQuery(sql);trywhile(rs.next()bookinfo bi=new bookinfo();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(

16、account);list.add(bi);rs.close();catch(SQLException e)jdbc.close();return list;public static bookinfo getbookbyid(String id)String sql=select * from book.bookshop where id=+id+; dbbean jdbc=new dbbean();ResultSet rs=jdbc.executeQuery(sql);bookinfo bi = new bookinfo();tryif(rs.next()bi.setDate(rs.get

17、String(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(SQLException e)jdbc.close();return bi;public static int updatebook(String id,String na

18、me,String author,String press,String date,int price,int account)int result=0;String sql=update book.bookshop setname=+name+,author=+author+,press=+press+,date=+date+,price=+price+,acco unt=+account+ where id=+id+;dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql); return result;public static in

19、t deletebook(String id)int result=0;String sql=delete from book.bookshop where id=+id+;dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;public static int addbook(String id,String name,String author,String press,String date,int price,int account)int result=0;String sql=insert int

20、o book.bookshop(id,name,author,press,date,price,account)values(+id+,+name+,+author+,+press+,+date+,+price+,+account+);dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;Dbbean.java:package bean;import java.lang.*;import java.sql.*;public class dbbeanprivate String name=root;privat

21、e String password=xyh201268;private Connection conn=null;private Statement stmt=null;public dbbean()tryClass.forName(driverStr);conn=DriverManager.getConnection(connStr,name,password); stmt=conn.createStatement();catch(Exception ex)public int executeUpdate(String s)int result=0;tryresult=stmt.execut

22、eUpdate(s);catch(Exception ex)return result;public ResultSet executeQuery(String s)ResultSet rs=null;tryrs=stmt.executeQuery(s);catch(Exception ex)return rs;public void close()trystmt.close();conn.close();catch(Exception ex)Servlet.java: package servlets; import java.lang.*; /* Created by Administra

23、tor on 14-5-31.*/public class Servlet extends HttpServlet protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException doPost(request, response);protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletExcepti

24、on, IOException request.setCharacterEncoding(utf-8);String action=request.getServletPath();if(action.equals(/servlets/depend.do)String value=request.getParameter(password);if(value.equals(123)request.setAttribute(list, list);request.getRequestDispatcher(/manager.jsp).forward(request,response);elsere

25、quest.setAttribute(list, list);request.getRequestDispatcher(/reader.jsp).forward(request,response);else if (action.equals(/servlets/list_m.do)request.setAttribute(list, list);request.getRequestDispatcher(/manager.jsp).forward(request,response);else if (action.equals(/servlets/list_r.do)request.setAt

26、tribute(list, list);request.getRequestDispatcher(/reader.jsp).forward(request,response);else if(action.equals(/servlets/edit.do)String id =request.getParameter(id);request.setAttribute(bi,bi);request.getRequestDispatcher(/edit.jsp).forward(request,response);else if(action.equals(/servlets/update.do)

27、String id=request.getParameter(id);String name=request.getParameter(name);String author=request.getParameter(author);String press=request.getParameter(press);String date=request.getParameter(date);String s_price=request.getParameter(price);String s_account=request.getParameter(account);int price=Int

28、eger.parseInt(s_price);int account=Integer.parseInt(s_account);if (r=1)request.getRequestDispatcher(/success_m.jsp).forward(request,response);elserequest.getRequestDispatcher(/failure_m.jsp).forward(request,response); else if (action.equals(/servlets/delete.do)String id=request.getParameter(id);if (

29、r=1)request.getRequestDispatcher(/success_m.jsp).forward(request,response);elserequest.getRequestDispatcher(/failure_m.jsp).forward(request,response); else if (action.equals(/servlets/add.do)String id=request.getParameter(id);String name=request.getParameter(name);String author=request.getParameter(

30、author);String press=request.getParameter(press);String date=request.getParameter(date);String s_price=request.getParameter(price);String s_account=request.getParameter(account);int price=Integer.parseInt(s_price);int account=Integer.parseInt(s_account);if (r=1)request.getRequestDispatcher(/success_

31、m.jsp).forward(request,response);elserequest.getRequestDispatcher(/failure_m.jsp).forward(request,response);else if (action.equals(/servlets/buy.do)String buy=request.getParameter(buy);request.setAttribute(bi,bi);request.getRequestDispatcher(/buy.jsp).forward(request,response);else if (action.equals

32、(/servlets/search_r.do)String id=request.getParameter(id);String name=request.getParameter(name);String author=request.getParameter(author);String user=request.getParameter(user);request.setAttribute(list, list);if (user.equals(reader)request.getRequestDispatcher(/sear_result_r.jsp).forward(request,

33、response);if (user.equals(manager)request.getRequestDispatcher(/sear_result_m.jsp).forward(request,response);else if (action.equals(/servlets/check_buy.do)String id=request.getParameter(id);String s_num_buy=request.getParameter(num_buy);int num_buy=Integer.parseInt(s_num_buy);if(bi.getAccount()=num_

34、buy)request.setAttribute(bi,bi);request.setAttribute(s_num_buy,s_num_buy);request.getRequestDispatcher(/success_buy.jsp).forward(request,response);elserequest.getRequestDispatcher(/failure_r.jsp).forward(request,response);else if (action.equals(/servlets/print_order.do)String id=request.getParameter

35、(id);String s_num_buy=request.getParameter(s_num_buy);int num_buy=Integer.parseInt(s_num_buy);request.getRequestDispatcher(/print_order.jsp).forward(request,response);Add_book.jsp:H 書信息 編號(hào) *(不能為 空) 書名 *(不能 為空)作者 *(不 能為空) 出版社 *(不 能為空)th class=item版日期 *(不能為空) 價(jià)格 *(只 能數(shù)字) 庫存 *(只能數(shù)字)buy.jsp:邛訂單信息#input

36、type=text value= name=name 書名 input type=text value= name=name #input type=text value= name=author vtdvinput type=text value二”v%二 bi.getPress()% name=press th class=出版日期 input type=text value= name=date input type=text value= name=price J$f input type=text value= name=account 購買數(shù)量 edit.jsp:vh2vcapti

37、on修改信息 #input type=text value= name=id 書名 input type=text value= name=name #input type=text value= name=author H4tt input type=text value= name=press th class=出版日期 input type=text value= name=date 價(jià)格 v/thvtdvinput type=text value=, name=price S#input type=text value= name=account failure_m.jsp:vh2操作

38、失敗 點(diǎn)擊返回 failure_r.jsp:vh2購買信息錯(cuò)誤 點(diǎn)擊返回 index.html:圖書商店用戶登錄legend客/管理員登錄 用戶名 *(顧客不用輸入) 密碼 *(顧客不用輸入) 記住我您忘記密碼? 友請(qǐng)連接 sina Copyright 2014-2015NETWORK.席簌海 鄧勻翔 袁野manager.jsp:a href=/bookshop/add_book.jsp”麻力口圖書 a href=/bookshop/search_r.jsp?user=” 點(diǎn)擊查詢 編號(hào) 書名 作者 出版社 出版日期 價(jià)格 庫存 管理 %request.setCharacterEncoding

39、(utf-8);ArrayList list=(ArrayList)request.getAttribute(list); for(bookinfo bi:list)String id=bi.getId();%a href=/bookshop/servlets/edit.do?id=” 修改 a href=/bookshop/servlets/delete.do?id=U 除 返回主頁 print_order.jsp:正在打印訂單,請(qǐng)稍候.a href=/bookshop/servlets/list_r.do也回主頁 reader.jsp: 現(xiàn)有圖書信息 a href=/bookshop/search_r.jsp?user=,點(diǎn)擊查詢 編號(hào) 書名 作者 出版社 出版日期 價(jià)格 庫存 購買 %request.setCharacterEncoding(utf-8);ArrayList list

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論