JavaWeb專業(yè)課程設(shè)計(jì)圖書(shū)館標(biāo)準(zhǔn)管理系統(tǒng)_第1頁(yè)
JavaWeb專業(yè)課程設(shè)計(jì)圖書(shū)館標(biāo)準(zhǔn)管理系統(tǒng)_第2頁(yè)
JavaWeb專業(yè)課程設(shè)計(jì)圖書(shū)館標(biāo)準(zhǔn)管理系統(tǒng)_第3頁(yè)
JavaWeb專業(yè)課程設(shè)計(jì)圖書(shū)館標(biāo)準(zhǔn)管理系統(tǒng)_第4頁(yè)
JavaWeb專業(yè)課程設(shè)計(jì)圖書(shū)館標(biāo)準(zhǔn)管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

JavaWeb課程設(shè)計(jì)

試驗(yàn)匯報(bào)

班級(jí):計(jì)算機(jī)09-2

試驗(yàn)內(nèi)容:圖書(shū)館管理系統(tǒng)

組員:趙伯濤44號(hào)(組長(zhǎng))

張寶紅42號(hào)

黃海清22號(hào)

試驗(yàn)時(shí)間:從12月3日

至12月9日

指導(dǎo)老師:李啟銳

一、試驗(yàn)?zāi)繕?biāo)。

1、在實(shí)踐中鞏固本學(xué)習(xí)所學(xué)Java呢b技術(shù)。

2、在實(shí)踐中初步使用設(shè)計(jì)模式(GoF),體驗(yàn)設(shè)計(jì)模式帶來(lái)好處。

3、配合數(shù)據(jù)庫(kù)使用,實(shí)現(xiàn)一個(gè)功效完善小型系統(tǒng)。

二、試驗(yàn)內(nèi)容。

開(kāi)發(fā)一個(gè)圖書(shū)管理系統(tǒng),實(shí)現(xiàn)圖書(shū)館多種管理操作。圖書(shū)入庫(kù)、作廢,

借書(shū)證提供、掛失處理,圖書(shū)借出、歸還、續(xù)借、丟失和超期處理。s

三、業(yè)務(wù)邏輯。

END

權(quán)限與操作

理斌管M另

四、數(shù)據(jù)庫(kù)設(shè)計(jì)。

依據(jù)業(yè)務(wù)邏輯設(shè)計(jì)出數(shù)據(jù)庫(kù)。表結(jié)構(gòu)及關(guān)系以下圖:

vy

采取了類似和MVC框架框架結(jié)構(gòu),頁(yè)面端使用了ExtJS技術(shù)(包含AJAX),

增加了業(yè)務(wù)層和,數(shù)據(jù)庫(kù)操作層。控制器層調(diào)用業(yè)務(wù)層,業(yè)務(wù)層調(diào)用數(shù)據(jù)

庫(kù)操作層。將控制,業(yè)務(wù),數(shù)據(jù)庫(kù)操作分別分層。

六、技術(shù)性代碼。

(本試驗(yàn)代碼在Library,zip中)

1、tomcat數(shù)據(jù)庫(kù)連接池技術(shù)。在tomcat中配置文件server,xml文件

中配置項(xiàng)目Context標(biāo)簽,再加入Resource標(biāo)簽:

<Contextpath二〃LibraryOA”

docBase=/z/home/sea/MyEclipse/LibraryOA/WebRoot,/

debug=〃0〃>

<Resource

name="jdbc/webdb”

auth=*Container*

type="javax.sql.DataSource”

driverClassName=z,org.gjt.mm.mysql.Driver*

url=*jdbc:mysql://localhost:3306/LibraryOA*

username="root"

password="root"

maxActive="50"

maxIdie="20"

maxWait=”10000”/>

</Context>

以上代碼配置了數(shù)裾庫(kù)驅(qū)動(dòng),數(shù)據(jù)庫(kù)地址,數(shù)據(jù)庫(kù)用戶名、密碼,默認(rèn)

提供連接數(shù),最大提供連接數(shù),最長(zhǎng)等候時(shí)間等參數(shù)。

2、Java中從連接池獲取連接類,使用了單例模式(來(lái)自GoF提出設(shè)計(jì)

模式):

//DataBaseConnectionPond.java

packagelibrary,util;

importjava.sql.Connection;

importjavax.sql.DataSource;

〃作者:趙伯濤

publicclassDataBaseConnectionPond(

privatestaticDataBaseConnectionPonddbcp=null;

privateDataSourceds=null;

privateDataBaseConnectionPond()throwsException(

javax.naming.Contextctx=newjavax.naming.TnitialContext();

ds=(DataSource)ctx.lookup(/zjava:/corop/env/jdbc/webdb,/);

}

publicConnectionGetConnettion()throwsException(

returnds.getConnection();

}

publicstaticConnectiongetConnection()throwsException(

Connectionconn=null;

if(dbcp==null){

Thread.sleep((long)(Math,random()*200));

synchronized(DataBaseConnectionPond.class){

if(dbcp==null){

dbcp=newDataBaseConnectionPond();

)

}

)

try(

conn=dbcp.GetConnettion();

}catch(Exceptione){

)

returnconn;

)

}

該類在整個(gè)項(xiàng)目布署過(guò)程中只實(shí)例化了一個(gè)對(duì)象,故稱單例。能夠經(jīng)過(guò)

該類static函數(shù)getConnectionO獲取連接。

3、Dao(DataAccessObject)模板化實(shí)現(xiàn),使用了模板方法模式(來(lái)自

GoF提出設(shè)計(jì)模式):

//SqlExecute.java

packcige1ibrary.execute;

importjava.sql.Connection;

import1ibrary.util.*;

〃作者:趙伯濤

publicabstractclassSqlExecute{

publicConnectionconn;

publicObjectresult;

publicabstractvoidsetExecute()throwsException;

publicObjectexecute(){

try{

conn=DataBaseConnectionPond.getConnectionO;

conn.setAutoCommit(false);

setExecute();

conn,commit();

}catch(Exceptione){

try(

conn,rollback();

}catch(Exceptionee){

)

e.printStackTrace();

}finally{

try(

conn.close0:

}catch(Exceptione){

}

)

returnresult;

)

2

該類是一個(gè)抽象類,必需經(jīng)過(guò)繼承該類來(lái)實(shí)現(xiàn)具體功效,其中execute()

函數(shù)是一個(gè)模板方法,將try-catch-finaly、獲取connection及

connection事務(wù)處理提取出來(lái),具體Dao功效應(yīng)該寫(xiě)在setExecuteO函數(shù)

中,在具體實(shí)現(xiàn)Dao功效時(shí)候能夠不用反復(fù)這些代碼,方便程序員編碼,

也方便程序員維護(hù)程序。下面舉例使用這個(gè)模板類:

//ReaderChangePasswordDao.java

packcige1ibrary.dao;

importjava.sql.PreparedStatement;

importlibrary,execute.SqlExecute;

importlibrary,model.ReaderModel;

〃作者:趙伯濤

publicclassReaderChangePasswordDaoextendsSqlExecute{

privateReaderModelrm;

//傳入readerlD,password,password2(舊密碼)

//返回影響行數(shù)

publicReaderChangePasswordDao(ReaderModelrm){

this,rm=rm;

?Override

publicvoidsetExecuteOthrowsException{

Stringsql="updateReaderssetpassword=?wherereaderlD=?

andpassword=?〃;

PreparedStatementps=conn.prepareStatement(sql);

ps.setString(Lrm.getPassword0):

ps.setlnt(2,rm.getReaderlDO);

ps.setString(3,rm.getPassword2());

this,result=ps.executeUpdate();

)

}

上面類繼承了SqlExecute類,重寫(xiě)了它setExecute()函數(shù),經(jīng)過(guò)結(jié)構(gòu)

函數(shù)傳入操作時(shí)需要參數(shù),在寫(xiě)代碼時(shí)候能夠愈加專注于數(shù)據(jù)庫(kù)操作,因

為其它操作由模板類做好了。這對(duì)寫(xiě)一個(gè)數(shù)據(jù)庫(kù)操作或許沒(méi)什么大不了,

不過(guò)一個(gè)項(xiàng)目里邊數(shù)據(jù)庫(kù)操作肯定是幾十個(gè),兒百個(gè),甚至幾千個(gè),使用

模板類降低編碼量是很客觀。下面舉例使用ReaderChangePasswordDao類:

〃來(lái)自UserCommonService.java部分代碼

//讀者修改密碼

publicbooleanreaderChangePassword(intreaderlD,String

newPassword,

StringoldPassword){

ReaderModelrm=newReaderModel();

rm.setReaderlD(readerlD);

rm.setPassword(newPassword);

rm.setPassword2(oldPassword);

ReaderChangePasswordDaorcpd=newReaderChangePasswordDao(rm):

intcount=(integer)rcpd.execute();

if(count>0)(

returntrue;

}else{

returnfalse;

}

}

注意:使用Dao時(shí)候調(diào)用應(yīng)該是它execute。方法(在抽象類中)。

4、時(shí)間顯示

varcTime=newDate。;〃初始化日期

varmyYear=cTime.getl'ullYear()://^p

varmyMonlh=cTime.gelMonlh()+l;〃月

varmyDate=cTime.getDateO://H

//取得時(shí)分秒

varmyHour=cTime.getHours();〃時(shí)

varmyMinutc=cTimc.gctMinutesO;〃分

varmySecond=cTime.getSecondsO;〃秒

if(myHour<10){〃判定假如時(shí)鐘小于10就顯示兩位,前一位用0替換

myHour='0'+myllour;

)

if(myMinute<10){〃判定假如分鐘小于10就顯示兩位,前一位用0替換

myinute='0'+myMinute;

)

ifGnySecond<10){〃判定假如分秒鐘小于10就顯示兩位,前一位用0替換

mySecond='0'+mySecond;

)

vartime=time=myYear+*/'+myMonth+,/'+myDate+,

+myHour+,+myMinute+,:'+mySecond;〃格式化時(shí)間

vartinier=setinterval(function(){//定義,個(gè)時(shí)鐘,周期為1秒

varcTimc=ncwDatcO;

varmyYear=cTimc.getFullYearO;//支持火狐

varmyMonth=cTime.getMonth()+l;//外國(guó)全部是以0開(kāi)頭為一月

varmyDate=cTime.getDateO;

〃取得時(shí)分秒

varmyHour=cTime.getHours();

varmyMinute=cTime.getMinutesO;

varmySecond=cTime.getSecondsO;

if(myHour<10){

myllour='O'+myHour;

}

if(myMinute<10){

myMinute='O'+myMinute:

}

if(mySecond<10){

mySecond='O'+mySccond;

}

varcmp=Ext.getCmp(*timer*);

time=myYear+,/'+myMonth+*/'+myDate+,

'+myHour+*:'+myMinute+,:'+mySecond:

cmp.setValuc(tinic);

},1000);

5、登錄控制

〃登錄界面

Ext.onReady(function(){

Ext.QuickTips.init();

varform-newExt.Panel({〃登錄臉證form

autoTabs:true,

activeTab:0.

deferredRender:false,

border:false,

bodyStyle:*background-color:RGB(193,223,232):padding:OpxOpxOpxOpx:*,

items:[(

xtype:,box,,

width:385,

height;80,

autoEi:{

tag:*img*,

sre:'icons/borrowbooks.jpg'

}

},(

xtype:*panel,,

bodyStyle;Jbackground-color:RGB(193,223,232),

layout:'hbox,,

items:LI

xtype:'panel,,

bodyStyle:'background-color:RGB(193,223,232),

border:faIse,

width:120,

height:150,

iterns:[{

xtype/panel,,

layout:'hbox",

border:false,

bodyStyle:'background-color:j?GB(193,223,232)jpadding:lOpxOpxOpx

lOpx*,

items:[{

xtype:'box',

width:*30',

height:'30',

autoEi:{

tag/img',

src:'icons/0.png'

)

),(

xtype:*panel,,

border:false,

bodyStyle:*background-color:RGB(193,223,232);padding:5pxOpx

OpxOpx',

iterns:[{

xtype/displayfield,,

value:*<ahref=>javascript::*

onclick=vicwWindow(,*+l.names[0]+w,)Xfontsize=2>查閱書(shū)目</font></a>"

}]

}]

},{

xtype:'panel,,

layout:*hbox,,

border:false,

bodyStyle:'background-color:RGB(193,223,232);padding:lOpxOpxOpx

lOpx,,

items:[{

xtype:*box>,

width:*30',

height/30',

autoEi:{

tag:'img',

src:"icons/6.png'

)

},{

xtype:*panel',

border:false,

bodyStyle:,background-color:RGB(193,223,232);padding:5pxOpx

OpxOpx',

items:[{

xtypc/displayficld't

value:"<ahref=,javascript:onclickriewWindowC"+"找回密

碼)><fontsize=2>找回密碼</fontX/a>"

}]

}]

}]

},{

xtype:,panel,,

border:false,

width:320,

height:150,

bodyStyle:Jbackground-color:RGB(193,223,232),

iterns:[(

xtype/panel',

layout?form',

border:false,

items:[{

xtype:,form,,

layout:*form',

id:'loginno,,

labclWidth:30,

bodyStyle:*background-color:RGB(193,223,232):padding:

15pxOpxOpxOpx',

border:false,

defaults:{

width:200

},

items:[{

xtype?textfield,,

fieldLabel:,編號(hào)',

allowBlank:false

}]

},{

xtype:*form*,

layout:'form',

id/loginpassword*,

labelWidlh:30,

bodyStyle:1bac<ground-color:RGB(193,223,232):padding:

lOpxOpxOpxOpx',

border:faIse,

defaults:{

width:200

),

items:[{

xtype:*textfield',

fieldLabel/密碼',

inputType:'password",

allowBlank:false

}]

}]

}]

}]

}]

!);

functionloginO{〃登錄驗(yàn)證函數(shù)

varformNo=Ext.getCmpf^loginno*);

varformPassword=Ext.getCmp(,,loginpassword/,);

varusername=formNo.items,iterns[0];

varpassword=formPassword.items.iterns[0]:

if(username.getValue().trim()!=""&&password.getValueO.trim()!=""){

Ext.Ajax,request({

urlservlet/LoginServlet,,

success:function(response){

varresult=Ext.decode(response.rcsponscTcxt);

if(result,success){

location,href="index,hlml”;

loginWindow.closeO;

}else{

Wxt.Msg.alert('提醒

,result,msg,function()(

formPassword.getFormO.rcsctO;

I);

};

},

params:{

emd:'login,,

username:username.getValueO.

password:passwoi'd.getValueO.trim()

},

scope:this

}):

}else{

Ext,Msg.alert('提醒','編號(hào)和密碼全部不能為空!');

)

}

varloginWindow=newExt.Window((〃登錄窗口

title:‘用戶登錄

layout:*fit',

width:400,

height:240,

shadow:true,

shadowOffset:5,

□lain:true,

naximizable:false,

draggable:false,

closable:false,

resizable:false,

animateTarget:document,body,

iterns:[form],

<eys:[{〃給登錄按鈕添加事件

key:Ext.EventObject.ENTER,

fn:fundion(){

1oginO;

),

scope:this

I],

buttons:[{

icon:'icons/accept.png',

text:'登錄',

handler:functionO{

1oginO;

)

I,(

icon:'icons/rss_go.png',

text:'重置',

hand1er:funclion(){

varformNo=Ext.getCmp("loginno");

varformPassword=Ext.getCmp(Mloginpassword*);

formNo.getEormO.reset():

formPassword.getFormO.reset();

)

I]

});

loginWindow.show。;〃顯示登錄窗口

}):

七、效果截圖。

查閱書(shū)目

個(gè)人資料

6注滿

圖書(shū)金作X

借書(shū)三三*/修

3優(yōu):I過(guò)MW吉I信QQP

借書(shū)證號(hào):09000001|◎于定姓名:張一字號(hào):0901010101

I,.............%

圖書(shū)編號(hào):A300001學(xué)院:學(xué)院A專北:專業(yè)11

班級(jí):專1H109-1Email:skylove@QQ.com

聯(lián)系電話:666004性別:里

UJIH

編號(hào):A300001

名稱:列寧1111己借圖書(shū)

是否借出:否美號(hào)名稱作者

計(jì)算機(jī)俎或原理

圖書(shū)類型:馬克思主義、列寧主義、毛A300006zbh

澤東思想、鄧小平理論A300005JAVAWEB李啟錢

作者:作者mi

出版時(shí)間:20054)2-25

單價(jià):32.5

出版社:人民日?qǐng)?bào)出版科

G笈吾讀僭◎借書(shū)

o

圖書(shū)操作

個(gè)人覽料

°

明書(shū)管厚:x

?知行

如*

圖書(shū)編Q用書(shū)名罄SB書(shū)兵工是杳僭出作業(yè)出收片閶Mffr出政世d

A300001列寧1111馬三毛主義.苑亍主.至住考11112005-02-2532.5人三日吸==?.三d

A300001曲小平人艮曰根比云松d

A300001鄧小軍馬克耳ARa?*?e

◎份

A300006子算機(jī)至茨京這一人要出版社u?

A300005JAVAWI8社會(huì)以人決出版行?

A300007單片機(jī)W會(huì)注人艮出版z◎

A000002高敢哲學(xué).清y出版社/◎

AD0009軍事智學(xué)..入艮出校七◎

A8單月機(jī)1杜翎人吳出版社?

10策片機(jī)2旱克m清y出粒松0◎

10港書(shū)哲學(xué)、ERE

圖書(shū)管理□X

◎方加£?別新

圣書(shū)片號(hào)國(guó)書(shū)名程為三類型是否管出作考出版時(shí)可單俠出版社

A300001列十1111胃立區(qū)主義、列十主.舌作看11112005-02-2532.5人民日杰出我行

A300001大小平馬競(jìng).巴主義、列于主.否作拿11112005-02-2532.5人民日繳出吸牡

A300001R小干馬三思主乂、列亍主.否作¥11112005-02-2532.5人民已嗖出稅七

A300006"算嘰維戌?窿芍手、關(guān)教是zbh2011-12-091002人民出版行

A300005JAVAWEB社會(huì)科多總論是李弓皖2011-12-1012.6人民出債法

A300007成片機(jī)行含科竽總論否zbh2011-12-1516,3人民出板世

A000002斐數(shù)號(hào)學(xué)'袤蚊否zbh2011-12-1712.62清多出粒七

A00009軍事自學(xué)、奈鼓否zbh201M2-0913.5人民出校社

A8里片凱1社會(huì)科學(xué)息論否生至紅2011-12-09100人民出版社

10w片機(jī)2馬”思主義、列寧主.否黃W音2011-12-09120清冬出版蒞

10借書(shū)首季*?5e否ZBH2011-12-09100ERE

目理員甘一

W號(hào)名甘或別^

AOOOOOQ8圣之越運(yùn)管灌員A

AOOOOOOS老四理藪言理曼&

|A0000002趙一蕓近管理員A

A0000004A

A0000001A

?'.

A0000003

⑥清定。在消

管理員管理X

維號(hào)名稱級(jí)別操w作&

A0000008

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(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)論