freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

畢業(yè)論文設(shè)計-信息公示板類網(wǎng)站的設(shè)計與實現(xiàn)-資料下載頁

2025-01-12 20:13本頁面
  

【正文】 ord(DataSource datasource, String id) { ResultSet rs = null。 // String name=null。 // String password=null。 DB d = new DB(datasource)。 List l = new ArrayList()。 try { String sql = select * from tb_forum where id=39。 + id + 39。 rs = (sql)。 StringTrans s = new StringTrans()。 while (()) { ForumBean f = new ForumBean()。 ((id))。 ((forumname))。 ((manager))。 ((createtime))。 // ((datasource,(1)))。 // ((datasource))。 (f)。 } rs = null。 } catch (Exception e) { 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 27 ()。 } ()。 return l。 } 。 public int getCount(DataSource datasource, int forumid) { ResultSet rs = null。 // String name=null。 // String password=null。 DB d = new DB(datasource)。 int i = 0。 try { String sql = select count(*) from tb_topic where forumid=39。 + forumid + 39。 rs = (sql)。 while (()) { i = (1)。 } } catch (Exception e) { ()。 } ()。 return i。 } 。 public static int getResponseCount(DataSource datasource) { ResultSet rs = null。 // String name=null。 // String password=null。 DB d = new DB(datasource)。 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 28 int i = 0。 try { String sql = select count(*) from tb_response 。 rs = (sql)。 while (()) { i = (1)。 } } catch (Exception e) { ()。 } ()。 return i。 } public int getZtAndResponseCount(DataSource datasource) { // 取總貼子總數(shù) return getResponseCount(datasource) + getCount(datasource)。 } 題的總數(shù)。 public static int gettodayTopicCount(DataSource datasource) { ResultSet rs = null。 // String name=null。 // String password=null。 DB d = new DB(datasource)。 int i = 0。 try { String sql = select count(*) from tb_topic where (TO_DAYS(submittime)TO_DAYS(now())=0)。 rs = (sql)。 while (()) { i = (1)。 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 29 } } catch (Exception e) { ()。 } ()。 return i。 } 公共模塊設(shè)計 數(shù)據(jù)庫連接 1. 配置數(shù)據(jù)源 在 Struts 框 架 中 , 使 用 文 件 中 的datasources元素來配置數(shù)據(jù)源,數(shù)據(jù)源負(fù)責(zé)建立和特定數(shù)據(jù)庫的連接。 Java語言提供了 接口,所有與 java連接的數(shù)據(jù)源必須實現(xiàn)這個接口。 在 , datasources元素用于指定使用某種數(shù)據(jù)源,其中包括多個 ,setproperty元素,用于指定數(shù)據(jù)源的各種屬性,例如連接何種數(shù)據(jù)庫,連接數(shù)據(jù)庫用戶名、密碼等。在本系統(tǒng)中使用 datasources元素配置與 MySQL 數(shù)據(jù)庫的連接, datasource元素的 type屬性用來指定數(shù)據(jù)源的實現(xiàn)類,在這里使用由 Apache 公司提供的DBCP數(shù)據(jù)源。 配置數(shù)據(jù)源的關(guān)鍵代碼如下: datasources datasource type= key=dataSources setproperty property=driverClassName value= / setproperty property=url value=jdbc: / 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 30 setproperty value=20 property=maxCount / setproperty value=1 property=minCount / setproperty property=username value=root / setproperty property=password value=root / /datasource /datasources 配置數(shù)據(jù)源完成后,可以在 Action 類中訪問數(shù)據(jù)源。在 Struts 框架中的 類 中 定 義 了getDataSource(HttpRequest)方法,由于在 開發(fā)中擴展了 Action 類,所以可以直接在自定義的 Action類中使用 getDataSource(HttpRequest)方法。 關(guān)鍵代碼如下: //取 struts 配置的數(shù)據(jù)源 DataSource datasource = getDataSource(request,dataSources)。 2. 創(chuàng)建數(shù)據(jù)庫連接輔助類 在實際項目開發(fā)中,通常會把數(shù)據(jù)庫連接、操作數(shù)據(jù)表、關(guān)閉數(shù)據(jù)庫連接 方 法 封 裝 在 一 個 數(shù) 據(jù) 庫 輔 助 類 中 , 本 系 統(tǒng) 的 輔 助 類 為。創(chuàng)建數(shù)據(jù)庫輔助類得步驟如下: ( 1) 在一般情況下,會將數(shù)據(jù)庫連接代碼放入構(gòu)造函數(shù)中。 關(guān)鍵代碼如下: public DB(DataSource dataSource){ if (connect != null) return。 try { connect = ()。 } catch (SQLException e) { ()。 } } ( 2) 創(chuàng)建查詢數(shù)據(jù)庫表的方法。 關(guān)鍵代碼 如下: public ResultSet OpenSql(String sql){ 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 31 try{ stmt=(L_INSENSITIVE,)。 rs=(sql)。 }catch(SQLException ex){ ()。 try{ if(stmt!=null) ()。 }catch(Exception e){ ()。 } } return rs。 } ( 3) 當(dāng)向數(shù)據(jù)庫表中插入數(shù)據(jù)或需要改變數(shù)據(jù)表中的數(shù)據(jù)時,需要創(chuàng)建數(shù)據(jù)表插入方法。 關(guān)鍵代碼如下: public int ExecSql(String sql){ int result=0。 try{ stmt=()。 result=(sql)。 //()。 ()。 }catch(SQLException ex){ (())。 try{ if(stmt!=null) ()。 }catch(Exception e){ 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 32 ()。 } } return result。 } ( 4) 當(dāng)不需要訪問數(shù)據(jù)庫時,需要調(diào)用數(shù)據(jù)庫關(guān) 閉方法,避免系統(tǒng)資源的浪費。 數(shù)據(jù)庫關(guān)閉方法關(guān)鍵代碼如下: public void close() { try { if (stmt != null) { ()。 stmt = null。 } if (connect != null) { ()。 connect = null。 //(***************** a connection is closed)。 } } catch (Exception e) { (())。 }finally{ connect=null。 //(***************** a connection is closed finally)。 } } 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 33 配置消息資源文件 1. 在 置消息資源文件 在 文件中, messageresources元素用來配置本地化文本消息,使用 parameter 參數(shù)指定消息資源文件名。 Struts 框架對國際化的支持體現(xiàn)在能夠根據(jù)用戶操作系統(tǒng)的語言選擇使用合適的消息資源文件,如果客戶端的用戶使用中文操作系統(tǒng),Struts框架會依次搜索如下消息資源文件。 ( 1) 。 ( 2) 。 ( 3) 。 在應(yīng)用消息資源文件時,在 文件中配置消息資源,配置代碼如下所示: messageresources parameter= / 2. 使用消息資源文件綁定 Struts 組件 在 Action 控制器中,每一個 ActionMessage類對象都包含一條錯誤消息, ActionMessage 對象被保存到 ActionMessage對象中,然后調(diào)用父類定義的 saveError()方法,負(fù)責(zé)將 ActionMessage對象保存到 request范圍內(nèi)。 最后返 回 ActionForward 對象, Struts 框架 會根據(jù)ActionForward 對象包含的轉(zhuǎn)發(fā)信息轉(zhuǎn)發(fā)到相應(yīng)的視圖組件,同時在視圖組件中調(diào)用 html:error/標(biāo)簽,即可將 ActionMessage對象中的錯誤信息顯示出來。 關(guān)鍵代碼如下所示: ActionMessage error = new ActionMessage() Else if(i==0){ (,new ActionMessage(“ ” ))。 saveErrors(request,error)。 } 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 34 3. 對消息資源文件進行轉(zhuǎn)碼 當(dāng)創(chuàng)建中文消息資源文件后,如果在消息資源文件中輸入中文后,錯誤提示消息在視圖組件上顯示亂碼,這是沒有對其進行編碼,對其進行編碼后的關(guān)鍵代碼如下所示: =\u767B\u5F55\u5931\u8D25 =enter failed =\u5220\u9664\u6210\u529F =\u4FEE\u6539\u6210\u529F =\u6CE8\u518C\u6210\u529F =\u7528\u6237\u540D\u53EF\u4EE5\u4F7F\u7528 創(chuàng)建轉(zhuǎn)碼類 在項目開發(fā)過程中,數(shù)據(jù)庫的編碼通常是 ISO88591,而項目編碼是 UTFGBK、 GB2312 等,此時如果不對數(shù)據(jù)庫進行轉(zhuǎn)碼操作,頁面上的中文就會出現(xiàn)亂碼現(xiàn)象。 在本系統(tǒng)中, ISO88591編碼轉(zhuǎn)換為 UTF8的方法。關(guān)鍵代碼如下: public static String tranC(String chB) { String result=null。 byte temp[]。 try { temp=(iso88591)。 result=new String(temp,UTF8)。 }catch(UnsupportedEncodingException e) { (())。 } return result。 } 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 35 頁面模塊設(shè)計 用戶登錄模塊設(shè)計 用戶 必須通過登錄才可以查看論壇中的相關(guān)信息。在登錄窗口中輸入用戶名、密碼后,點擊“提交”按鈕,待身份驗證成功后,即可進入 BBS 論壇系統(tǒng)。 本系統(tǒng)的用戶分為 3個級別,分別為普通用戶、斑竹、管理員,其中普通用戶和斑竹登錄后直接進入瀏覽界面,可以瀏覽論壇中的相關(guān)主題,而管理員登錄后進入后臺管理頁面,可以修改論壇、用戶的相關(guān)信息等。 圖 用戶登錄頁面 1. 用戶登錄邏輯描述 在 Struts 框架中,使用 MVC 模式開發(fā) M 為模型,由 JavaBean 來實現(xiàn); V為視圖,由 JSP文件構(gòu)成; C為控制器,由 Action 來實現(xiàn)。本系統(tǒng)登錄模塊設(shè)計也遵循這種開發(fā)模式。 首先需要設(shè)計一個登錄視圖。在本系統(tǒng)中,登錄視圖為 文件,其主要功能是提供用戶登錄時填寫身份信息的表單。當(dāng)用戶提交表單后,系統(tǒng) 會自動根據(jù) 配置文件中的配置信息將表單數(shù)據(jù)提交到相應(yīng)的 Action控制器,在 Action 控制器中進行表單驗證操作,然后根據(jù)驗證結(jié)果轉(zhuǎn)入不同頁面。 2. 用戶登錄 實現(xiàn)過程 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 36 ( 1)配置登錄模塊組件 在 ,配置完成系統(tǒng)登錄功能。 關(guān)鍵代碼如下所示: action attribute=loginForm input=/ name=loginForm path=/login scope=request type= forward name=error path=/ / forward name=success path=/ / forward name=adminsuccess path=/ / /action ( 2) 創(chuàng)建視圖組件 在 ,配置完成系統(tǒng)登錄功能。 關(guān)鍵代碼如下所示: 視圖組件是模型的外在表現(xiàn)形式,使用 JSP文件表示。 此模塊視圖組件中包含一個登錄表單, 表單中包括用戶名文本框和密碼文本框 ,這兩個文本框的名稱要和模型組件中的屬性名稱相同,即LoginForm 類中的屬性值。 文件的關(guān)鍵代碼如下: html:form action= focus=name table width=527 height=356 border=0 align=center cellpadding=0 cellspacing=0 id=__01 tr td width=42% /td td width=58% valign=baselinehtml:text property=name size=20 maxlength=20//td /tr tr 信息公示板類網(wǎng)站的設(shè)計與實現(xiàn) 37 td /td td valign=baselinehtml:password property=password size=22 maxlength=20//td /tr /tabl
點擊復(fù)制文檔內(nèi)容
范文總結(jié)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1