基于SpringBoot+Bootstrap【爱码个人博客系统】附源码

简介: 基于SpringBoot+Bootstrap【爱码个人博客系统】附源码

前言介绍:


随着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("系统设置保存异常!");
        }
    }
}

论文参考:

目录
相关文章
|
9月前
|
JavaScript Java 关系型数据库
基于springboot的项目管理系统
本文探讨项目管理系统在现代企业中的应用与实现,分析其研究背景、意义及现状,阐述基于SSM、Java、MySQL和Vue等技术构建系统的关键方法,展现其在提升管理效率、协同水平与风险管控方面的价值。
|
9月前
|
搜索推荐 JavaScript Java
基于springboot的儿童家长教育能力提升学习系统
本系统聚焦儿童家长教育能力提升,针对家庭教育中理念混乱、时间不足、个性化服务缺失等问题,构建科学、系统、个性化的在线学习平台。融合Spring Boot、Vue等先进技术,整合优质教育资源,提供高效便捷的学习路径,助力家长掌握科学育儿方法,促进儿童全面健康发展,推动家庭和谐与社会进步。
|
9月前
|
JavaScript Java 关系型数据库
基于springboot的古树名木保护管理系统
本研究针对古树保护面临的严峻挑战,构建基于Java、Vue、MySQL与Spring Boot技术的信息化管理系统,实现古树资源的动态监测、数据管理与科学保护,推动生态、文化与经济可持续发展。
|
9月前
|
监控 安全 JavaScript
2025基于springboot的校车预定全流程管理系统
针对传统校车管理效率低、信息不透明等问题,本研究设计并实现了一套校车预定全流程管理系统。系统采用Spring Boot、Java、Vue和MySQL等技术,实现校车信息管理、在线预定、实时监控等功能,提升学校管理效率,保障学生出行安全,推动教育信息化发展。
|
10月前
|
存储 JavaScript Java
基于springboot的大学公文收发管理系统
本文介绍公文收发系统的研究背景与意义,分析其在数字化阅读趋势下的必要性。系统采用Vue、Java、Spring Boot与MySQL技术,实现高效、便捷的公文管理与在线阅读,提升用户体验与信息处理效率。
|
9月前
|
人工智能 Java 关系型数据库
基于springboot的画品交流系统
本项目构建基于Java+Vue+SpringBoot+MySQL的画品交流系统,旨在解决传统艺术交易信息不透明、流通受限等问题,融合区块链与AI技术,实现画品展示、交易、鉴赏与社交一体化,推动艺术数字化转型与文化传播。
|
9月前
|
JavaScript Java 关系型数据库
基于springboot的高校运动会系统
本系统基于Spring Boot、Vue与MySQL,实现高校运动会报名、赛程安排及成绩管理的全流程信息化,提升组织效率,杜绝信息错漏与冒名顶替,推动体育赛事智能化发展。
|
9月前
|
JavaScript 安全 Java
基于springboot的大学生兼职系统
本课题针对大学生兼职信息不对称、权益难保障等问题,研究基于Spring Boot、Vue、MySQL等技术的兼职系统,旨在构建安全、高效、功能完善的平台,提升大学生就业竞争力与兼职质量。
|
9月前
|
JavaScript Java 关系型数据库
基于springboot的美食城服务管理系统
本系统基于Spring Boot、Java、Vue和MySQL技术,构建集消费者服务、商家管理与后台监管于一体的美食城综合管理平台,提升运营效率与用户体验。