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

正文內容

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

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) { 信息公示板類網站的設計與實現 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)。 信息公示板類網站的設計與實現 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) { // 取總貼子總數 return getResponseCount(datasource) + getCount(datasource)。 } 題的總數。 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)。 信息公示板類網站的設計與實現 29 } } catch (Exception e) { ()。 } ()。 return i。 } 公共模塊設計 數據庫連接 1. 配置數據源 在 Struts 框 架 中 , 使 用 文 件 中 的datasources元素來配置數據源,數據源負責建立和特定數據庫的連接。 Java語言提供了 接口,所有與 java連接的數據源必須實現這個接口。 在 , datasources元素用于指定使用某種數據源,其中包括多個 ,setproperty元素,用于指定數據源的各種屬性,例如連接何種數據庫,連接數據庫用戶名、密碼等。在本系統(tǒng)中使用 datasources元素配置與 MySQL 數據庫的連接, datasource元素的 type屬性用來指定數據源的實現類,在這里使用由 Apache 公司提供的DBCP數據源。 配置數據源的關鍵代碼如下: datasources datasource type= key=dataSources setproperty property=driverClassName value= / setproperty property=url value=jdbc: / 信息公示板類網站的設計與實現 30 setproperty value=20 property=maxCount / setproperty value=1 property=minCount / setproperty property=username value=root / setproperty property=password value=root / /datasource /datasources 配置數據源完成后,可以在 Action 類中訪問數據源。在 Struts 框架中的 類 中 定 義 了getDataSource(HttpRequest)方法,由于在 開發(fā)中擴展了 Action 類,所以可以直接在自定義的 Action類中使用 getDataSource(HttpRequest)方法。 關鍵代碼如下: //取 struts 配置的數據源 DataSource datasource = getDataSource(request,dataSources)。 2. 創(chuàng)建數據庫連接輔助類 在實際項目開發(fā)中,通常會把數據庫連接、操作數據表、關閉數據庫連接 方 法 封 裝 在 一 個 數 據 庫 輔 助 類 中 , 本 系 統(tǒng) 的 輔 助 類 為。創(chuàng)建數據庫輔助類得步驟如下: ( 1) 在一般情況下,會將數據庫連接代碼放入構造函數中。 關鍵代碼如下: public DB(DataSource dataSource){ if (connect != null) return。 try { connect = ()。 } catch (SQLException e) { ()。 } } ( 2) 創(chuàng)建查詢數據庫表的方法。 關鍵代碼 如下: public ResultSet OpenSql(String sql){ 信息公示板類網站的設計與實現 31 try{ stmt=(L_INSENSITIVE,)。 rs=(sql)。 }catch(SQLException ex){ ()。 try{ if(stmt!=null) ()。 }catch(Exception e){ ()。 } } return rs。 } ( 3) 當向數據庫表中插入數據或需要改變數據表中的數據時,需要創(chuàng)建數據表插入方法。 關鍵代碼如下: public int ExecSql(String sql){ int result=0。 try{ stmt=()。 result=(sql)。 //()。 ()。 }catch(SQLException ex){ (())。 try{ if(stmt!=null) ()。 }catch(Exception e){ 信息公示板類網站的設計與實現 32 ()。 } } return result。 } ( 4) 當不需要訪問數據庫時,需要調用數據庫關 閉方法,避免系統(tǒng)資源的浪費。 數據庫關閉方法關鍵代碼如下: 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)。 } } 信息公示板類網站的設計與實現 33 配置消息資源文件 1. 在 置消息資源文件 在 文件中, messageresources元素用來配置本地化文本消息,使用 parameter 參數指定消息資源文件名。 Struts 框架對國際化的支持體現在能夠根據用戶操作系統(tǒng)的語言選擇使用合適的消息資源文件,如果客戶端的用戶使用中文操作系統(tǒng),Struts框架會依次搜索如下消息資源文件。 ( 1) 。 ( 2) 。 ( 3) 。 在應用消息資源文件時,在 文件中配置消息資源,配置代碼如下所示: messageresources parameter= / 2. 使用消息資源文件綁定 Struts 組件 在 Action 控制器中,每一個 ActionMessage類對象都包含一條錯誤消息, ActionMessage 對象被保存到 ActionMessage對象中,然后調用父類定義的 saveError()方法,負責將 ActionMessage對象保存到 request范圍內。 最后返 回 ActionForward 對象, Struts 框架 會根據ActionForward 對象包含的轉發(fā)信息轉發(fā)到相應的視圖組件,同時在視圖組件中調用 html:error/標簽,即可將 ActionMessage對象中的錯誤信息顯示出來。 關鍵代碼如下所示: ActionMessage error = new ActionMessage() Else if(i==0){ (,new ActionMessage(“ ” ))。 saveErrors(request,error)。 } 信息公示板類網站的設計與實現 34 3. 對消息資源文件進行轉碼 當創(chuàng)建中文消息資源文件后,如果在消息資源文件中輸入中文后,錯誤提示消息在視圖組件上顯示亂碼,這是沒有對其進行編碼,對其進行編碼后的關鍵代碼如下所示: =\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)建轉碼類 在項目開發(fā)過程中,數據庫的編碼通常是 ISO88591,而項目編碼是 UTFGBK、 GB2312 等,此時如果不對數據庫進行轉碼操作,頁面上的中文就會出現亂碼現象。 在本系統(tǒng)中, ISO88591編碼轉換為 UTF8的方法。關鍵代碼如下: public static String tranC(String chB) { String result=null。 byte temp[]。 try { temp=(iso88591)。 result=new String(temp,UTF8)。 }catch(UnsupportedEncodingException e) { (())。 } return result。 } 信息公示板類網站的設計與實現 35 頁面模塊設計 用戶登錄模塊設計 用戶 必須通過登錄才可以查看論壇中的相關信息。在登錄窗口中輸入用戶名、密碼后,點擊“提交”按鈕,待身份驗證成功后,即可進入 BBS 論壇系統(tǒng)。 本系統(tǒng)的用戶分為 3個級別,分別為普通用戶、斑竹、管理員,其中普通用戶和斑竹登錄后直接進入瀏覽界面,可以瀏覽論壇中的相關主題,而管理員登錄后進入后臺管理頁面,可以修改論壇、用戶的相關信息等。 圖 用戶登錄頁面 1. 用戶登錄邏輯描述 在 Struts 框架中,使用 MVC 模式開發(fā) M 為模型,由 JavaBean 來實現; V為視圖,由 JSP文件構成; C為控制器,由 Action 來實現。本系統(tǒng)登錄模塊設計也遵循這種開發(fā)模式。 首先需要設計一個登錄視圖。在本系統(tǒng)中,登錄視圖為 文件,其主要功能是提供用戶登錄時填寫身份信息的表單。當用戶提交表單后,系統(tǒng) 會自動根據 配置文件中的配置信息將表單數據提交到相應的 Action控制器,在 Action 控制器中進行表單驗證操作,然后根據驗證結果轉入不同頁面。 2. 用戶登錄 實現過程 信息公示板類網站的設計與實現 36 ( 1)配置登錄模塊組件 在 ,配置完成系統(tǒng)登錄功能。 關鍵代碼如下所示: 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)登錄功能。 關鍵代碼如下所示: 視圖組件是模型的外在表現形式,使用 JSP文件表示。 此模塊視圖組件中包含一個登錄表單, 表單中包括用戶名文本框和密碼文本框 ,這兩個文本框的名稱要和模型組件中的屬性名稱相同,即LoginForm 類中的屬性值。 文件的關鍵代碼如下: 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 信息公示板類網站的設計與實現 37 td /td td valign=baselinehtml:password property=password size=22 maxlength=20//td /tr /tabl
點擊復制文檔內容
范文總結相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1