https://www.eclipse.org/downloads/

2、去官網(wǎng)下載相應(yīng)版本的jdk文件,并安裝

https://www.oracle" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運營 > 博客網(wǎng)站的設(shè)計與實現(xiàn)

博客網(wǎng)站的設(shè)計與實現(xiàn)

時間:2023-09-19 23:24:01 | 來源:網(wǎng)站運營

時間:2023-09-19 23:24:01 來源:網(wǎng)站運營

博客網(wǎng)站的設(shè)計與實現(xiàn):

1、配置開發(fā)環(huán)境

1.1 下載安裝eclipse,JDK環(huán)境配置步驟:

1、去官網(wǎng)下載對應(yīng)版本的eclipse,并安裝

https://www.eclipse.org/downloads/

2、去官網(wǎng)下載相應(yīng)版本的jdk文件,并安裝

https://www.oracle.com/technetwork/java/javase/downloads/index.html

3、去配置java環(huán)境

1)我的電腦->右鍵->屬性->高級系統(tǒng)設(shè)置->環(huán)境變量設(shè)置

2)點擊新建,變量名:path,變量值:剛剛JDK的安裝路徑,

例如:C:/Programles/Java/jdk1.8.0_121/bin。

3)同樣新建,變量名:classpath,變量值:C:/Program Files/Java/jdk1.8.0_121/jre/lib/rt.jar

4)接下來可以打開DOS命令(運行:CMD)輸入javac,顯示如下圖一樣就說明完成了eclipse的配置。

1.2 下載安裝MySQL:

1、去官網(wǎng)下載并安裝最新版

https://dev.mysql.com/downloads/installer/

2、看自己需要需要安裝即可,注意不要忘記自己設(shè)置的用戶名和密碼

1.3下載安裝 Navicat for MySQL:

1、去官網(wǎng)下載

http://www.formysql.com/xiazai_mysql.html

2、以管理員身份運行安裝包

3、打開后輸入注冊碼

4、注冊成功之后連接到MySQL數(shù)據(jù)庫。點擊左上角的【連接】圖標(biāo),連接名可以任意起,其中,因為我們是本地連接,所以是主機名是“l(fā)ocalhost”,IP是“127.0.0.1”,密碼是我們剛才設(shè)置的mysql密碼。

3、系統(tǒng)實現(xiàn)的功能

本系統(tǒng)采用jsp技術(shù),基于MVC模式開發(fā),使用SSH框架(struts2、spring、hibernate)來增加系統(tǒng)的開發(fā)速度。所謂的MVC模式是"Model-View-Controller"的縮寫,中文翻譯為"模式-視圖-控制器"。程序就是用struts2和hibernate這兩個框架來實現(xiàn)模型層和控制器這兩層,jsp實現(xiàn)視圖這一層。

三、系統(tǒng)實現(xiàn)的功能

4、系統(tǒng)關(guān)鍵代碼(部分)

4.1 用戶登錄

//用戶登錄 public String login2() throws IOException { HttpServletRequest request = this.getRequest(); PrintWriter writer = this.getPrintWriter(); String username = request.getParameter("username"); String password = request.getParameter("password"); User user = userDao.selectBean(" where username = '" + username + "' and password= '" + password + "' and deletestatus=0 and role=2 and status=0 "); if (user != null) { HttpSession session = request.getSession(); session.setAttribute("user", user); writer.print("<script language=javascript>window.location.href='index.action';</script>"); } else { writer.print("<script language=javascript>alert('用戶名或者密碼錯誤或者賬戶已封禁');window.location.href='indexmethod!login.action';</script>"); } return null; }說明:本段代碼是程序的登陸代碼,首先從獲取從頁面輸入的用戶名、密碼,然后調(diào)用userDao.selectBean方法,從數(shù)據(jù)庫里取出該條記錄進(jìn)行判斷,如果該條記錄存在,則說明:用戶登陸成功,同時把用戶信息存在session里面方便調(diào)用,如果記錄為空,則跳轉(zhuǎn)到登陸頁面,同時提醒用戶錯誤信息。

4.2 博文管理

//博文列表 public String articlelist() { HttpServletRequest request = this.getRequest(); String atitle = request.getParameter("atitle"); StringBuffer sb = new StringBuffer(); sb.append(" where "); if (atitle != null && !"".equals(atitle)) { sb.append("atitle like '%" + atitle + "%'"); sb.append(" and "); request.setAttribute("atitle", atitle); } HttpSession session = request.getSession(); User user = (User)session.getAttribute("user"); sb.append(" articledelete=0 and user.id="+user.getId()+" order by id desc "); String where = sb.toString(); int currentpage = 1; int pagesize = 10; if (request.getParameter("pagenum") != null) { currentpage = Integer.parseInt(request.getParameter("pagenum")); } int total = articleDao.selectBeanCount(where.replaceAll("order by id desc", "")); request.setAttribute("list", articleDao.selectBeanList((currentpage - 1) * pagesize, pagesize, where)); request.setAttribute("pagerinfo", Pager.getPagerNormal(total, pagesize, currentpage, "usermethod!articlelist.action", "共有" + total + "條記錄")); request.setAttribute("url", "usermethod!articlelist.action"); request.setAttribute("url2", "usermethod!article"); request.setAttribute("title", "博文管理"); this.setUrl("user/article/articlelist.jsp"); return SUCCESS; }說明:首先通過 String atitle = request.getParameter("atitle ");這句代碼從頁面獲取查詢的選項,然后通過if(atitle!=null &&!"".equals(atitle)){通過這句條件語句分別判斷下這個值是否為空,當(dāng)不為空時則通過StingBuffer 來疊加組裝查詢的sql語句,最后當(dāng)sql語句組裝好了之后,通過articleDao.selectBeanList方法來調(diào)用數(shù)據(jù)庫的查詢方法來查到符合條件的記錄,在通過request.setAttribute方法把查詢到的記錄傳到顯示的頁面。

同時通過this.setUrl("user/article/articlelist.jsp");方法指定傳回到具體指定的是哪個JSP頁面。通過這樣實現(xiàn)對數(shù)據(jù)查詢功能的實現(xiàn),同時在該博文列表頁面定義了對博文信息的增加,修改,刪除等操作。

5、系統(tǒng)錄屏

5.1系統(tǒng)管理員

主要管理用戶和博文管理員https://www.zhihu.com/video/1115373671254114304

5.2 游客和登陸的用戶

未登錄的游客和注冊登陸的用戶https://www.zhihu.com/video/1115374108850012160

5.3 博文管理員

主要管理對應(yīng)分類的博文及評論https://www.zhihu.com/video/1115374252416679936

關(guān)鍵詞:設(shè)計,實現(xiàn)

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點擊下載Chrome瀏覽器
關(guān)閉