前言介绍:
随着Internet的广泛应用,动态网页技术也应运而生。本文介绍了应用ASP动态网页技术开发博客系统的设计与实现,
博客系统主要为用户提供发表文章、浏览文章等功能,用户通过Internet 可以发表一些自己撰写的文章以和其他网友进行交流。博客系统主要实现了文章管理的数字化、信息化、智能化,是打破传统报刊、杂志发表文章方式的新尝试。本系统的开发设计实现采用JAVA技术,
系统后台使用SQL数据库,并通过使用JDBC技术访问。本文对博客系统进行整体分析,明确了系统的可行性和用户需求;根据模块化原理,规划设计了系统功能模块;在数据库设计部分,详细说明了系统数据库的结构和数据库的完整性、安全性措施;程序设计则采用面向对象的程序设计思想,提出系统的程序设计思路,对前台与后台功能的程序实现进行了详细论述;系统测试部分,具体分析测试过程中出现的主要问题,并提出了解决方案,实现系统功能。最后,对系统作以客观、全面的评价,并对进一步改进提出了建议。
With the wide application of Internet, dynamic web technology also arises at the historic moment. This paper introduces the design and implementation of the application of ASP dynamic web technology to develop the blog system. The blog system mainly provides users with the functions of publishing articles, browsing articles and so on. Users can publish some of their own articles through the Internet to communicate with other netizens. Blog system mainly realizes the digitalization, information and intelligence of article management, which is a new attempt to break the traditional way of publishing articles in newspapers and magazines. The development and design of this system adopts ASP technology, SQL Server 2008 database is used in the background of the system, and access by using ODBC technology. This article carries on the whole analysis to the blog system, has made clear the feasibility of the system and the user demand; According to the modularization principle, the functional modules of the system are planned and designed. In the database design part, detailed description of the system database structure and database integrity, security measures; The program design adopts object-oriented program design idea, puts forward the system program design idea, and discusses the program realization of the foreground and background function in detail. The system test part, the specific analysis of the test process of the main problems, and put forward solutions to achieve system functions. Finally, an objective and comprehensive evaluation of the system is made, and some suggestions for further improvement are put forward.
一、行业发展原因分析
个人博客能让个人在互联网上表达自己的心声。这是一个收集和共享任何感兴趣的事物的地方一可以是政治评论、个人日记或是指向您想记住的网站的链接。
它是一种简单有效的提供网络用户之间进行 在线交流的网络平台,通过个人博客可以结交更多的朋友, 表达更多的想法,它随时可以发布日志,方便快捷。个人博客作为一种新的表达方式,它传播的不仅是情绪,还包括大量的智慧、意见和思想。
从某种意义上说,它也是一种新的文化现象,个人博客的出现和繁荣,真正凸现了网络的知识价值,标志着互联网发展开始步入更高的阶段这样不仅促进了学习,更重要的是反映了一个人的在思想上的成长过程。访客可以直接在个人博客上留言,如提出问题或意见。通过研究开发本系统,使我们了解当今个人博客发展的最新动态,人博客对 以及个整个社会的影响力。同时,可以使我们掌握个人网站开发的基本方法和技术,为以后的实际开发莫定基础。
系统设计:
该项目是基于SpringBoot+Bootstrap【爱码个人博客系统】,下面做了功能和相关技术的描述,适合出入职场和即将进入职场的各位,如有问题欢迎留言。
系统总共分为几个大的模块。
博客系统分为两大模块:
1.博客前台页面,游客可以查看博主发表的文章,也可以注册后登录对博主文章进行评论
2.博客系统后台管理,管理员登录后可以发表,删除,修改文章,也可以对游客信息进行查看,修改等操作
一
运行环境
JDK8、Tomcat8、MySQL5.7、IntelliJ IDEA、Maven
- 核心技术:
Spring Boot2、MyBatis、Bootstrap、jQuery
账号:
如果使用原配置及数据库文件,可以使用一下方式登录
首页:<http://127.0.0.1:8080/> 账号:zhangsan zhangsan 后台:http://127.0.0.1:8080/admin/login 账号:admin admin
功能截图:
代码实现:
package com.lee.common; import java.util.ArrayList; import java.util.List; /** * 表格数据存储对象 * 默认作为bootstrap表格对应的数据结构存储对象 * author:lee */ public class DataGrid { private Long total = Long.valueOf(0); private List rows = new ArrayList(); public Long getTotal() { return total; } public void setTotal(Long total) { this.total = total; } public List getRows() { return rows; } public void setRows(List rows) { this.rows = rows; } }
package com.lee.controller.admin; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.lee.common.DataGrid; import com.lee.common.DateTimeUtil; import com.lee.common.Message; import com.lee.entity.Admin; import com.lee.entity.Article; import com.lee.service.ArticleService; import com.lee.service.CateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.Model; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.stereotype.Controller; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; /** * <p> * 前端控制器 * </p> * * @author lee * @since 2020-02-22 */ @Controller @RequestMapping("/admin/article") public class ArticleController extends BasicController { @Autowired ArticleService articleService; @Autowired CateService cateService; @GetMapping("list") public String list(){ return "admin/article/list"; } @PostMapping("findList") @ResponseBody public DataGrid findList(@RequestBody JSONObject jsonObject){ Map<String, Object> searchParams = (HashMap<String, Object>) jsonObject.get("search"); int offset = "".equals(jsonObject.getString("offset")) ? 0 : jsonObject.getIntValue("offset"); int size = "".equals(jsonObject.getString("limit")) ? 10 : jsonObject.getIntValue("limit"); IPage<Map<String, Object>> page = articleService.getPageInfo(searchParams, offset, size); DataGrid result = new DataGrid(); result.setTotal(page.getTotal()); result.setRows(page.getRecords()); return result; } @GetMapping("add") public String add(Model model) { model.addAttribute("cateInfos",cateService.getList()); return "admin/article/add"; } @PostMapping("add") @ResponseBody public Message doAdd(@Validated Article article, HttpServletRequest request){ try { Admin admin = getCurrentUser(request); if(admin != null) { if(article.getIsTop() == null) { article.setIsTop(0); } article.setCreateTime(DateTimeUtil.nowTimeStr()); article.setMemberId(admin.getId()); articleService.save(article); return Message.success("文章添加成功!"); } else { return Message.fail("登录超时,请重新登录!",null,"/admin/login"); } } catch (Exception e) { return Message.fail("文章数据保存异常,保存失败!"); } } @PostMapping("top") @ResponseBody public Message top(@RequestParam(value = "id")Integer id,@RequestParam(value = "istop")Integer istop){ try{ Article article = articleService.getById(id); if(article != null) { if(istop == 1) { article.setIsTop(0); } else if(istop == 0) { article.setIsTop(1); } articleService.updateById(article); return Message.success("操作成功!"); } else { return Message.fail("文章不存在或已被删除,操作失败!"); } } catch (Exception e) { return Message.fail("文章推荐操作处理异常!"); } } @GetMapping("/update/{id}") public String update(@PathVariable Integer id,Model model){ Article article = articleService.getById(id); model.addAttribute("cateInfos",cateService.getList()); model.addAttribute("articleInfo",article); return "admin/article/update"; } @PostMapping("/update") @ResponseBody public Message doUpdate(@Validated Article article){ try{ Article articleInfo = articleService.getById(article.getId()); if(articleInfo != null) { if(article.getIsTop() == null) { articleInfo.setIsTop(0); } else { articleInfo.setIsTop(article.getIsTop()); } articleInfo.setTitle(article.getTitle()); articleInfo.setAuthorname(article.getAuthorname()); articleInfo.setTags(article.getTags()); articleInfo.setArtdesc(article.getArtdesc()); articleInfo.setContent(article.getContent()); articleInfo.setCateId(article.getCateId()); articleInfo.setUpdateTime(DateTimeUtil.nowTimeStr()); articleService.updateById(articleInfo); return Message.success("文章修改成功!"); } else { return Message.fail("文章不存在或已被删除!"); } } catch (Exception e) { return Message.fail("文章修改保存异常,操作失败!"); } } @PostMapping("delete") @ResponseBody public Message delete(@RequestParam(value = "ids") List<Integer> ids) { try { for (int id : ids) { articleService.deleteArticleAndCommentById(id); } return Message.success("文章删除成功"); } catch (Exception e) { return Message.fail("文章删除异常!"); } } }
package com.lee.controller.admin; import com.lee.entity.Article; import com.lee.entity.Member; import com.lee.service.ArticleService; import com.lee.service.CommentService; import com.lee.service.MemberService; import com.sun.org.apache.xpath.internal.operations.Mod; import org.apache.catalina.Session; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import java.nio.channels.MembershipKey; @Controller @RequestMapping("/admin") public class HomeController { @Autowired MemberService memberService; @Autowired ArticleService articleService; @Autowired CommentService commentService; @RequestMapping("home") public String home(Model model){ int memberCount = memberService.count(); int articleCount = articleService.count(); int commentCount = commentService.count(); model.addAttribute("memberCount",memberCount); model.addAttribute("articleCount",articleCount); model.addAttribute("commentCount",commentCount); return "admin/home"; } /** * 退出管理 * @return */ @RequestMapping("logout") public String logout(HttpServletRequest request){ request.getSession().removeAttribute("admin"); if(request.getSession().getAttribute("admin") != null) { //ToDO session清空失败,可以跳转到退出失败页面 } // return "redirect:/admin/login"; return "admin/login"; } }
package com.lee.controller.admin; import com.lee.common.DateTimeUtil; import com.lee.common.Message; import com.lee.entity.Syssetting; import com.lee.service.SyssettingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.Model; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ResponseBody; import java.sql.Time; /** * <p> * 前端控制器 * </p> * * @author lee * @since 2020-02-24 */ @Controller @RequestMapping("/admin/syssetting") public class SyssettingController { @Autowired SyssettingService syssettingService; @GetMapping("add") public String add(Model model){ Syssetting syssetting = syssettingService.getById(1); if(syssetting != null) { model.addAttribute("syssetting",syssetting); } return "admin/syssetting/add"; } @PostMapping("add") @ResponseBody public Message doAdd(@Validated Syssetting syssetting){ try{ Syssetting syssettingInfo = syssettingService.getById(1); if (syssettingInfo == null) { syssettingInfo = new Syssetting(); syssettingInfo.setCopyright(syssetting.getCopyright()); syssettingInfo.setWebname(syssetting.getWebname()); syssettingInfo .setCreateTime(DateTimeUtil.nowTimeStr()); syssettingInfo.setSign(syssetting.getSign()); syssettingService.save(syssettingInfo); } else { syssettingInfo.setCopyright(syssetting.getCopyright()); syssettingInfo.setWebname(syssetting.getWebname()); syssettingInfo .setUpdateTime(DateTimeUtil.nowTimeStr()); syssettingInfo.setSign(syssetting.getSign()); syssettingService.updateById(syssettingInfo); } return Message.success("系统设置保存成功"); } catch (Exception e) { return Message.fail("系统设置保存异常!"); } } }
论文参考: