——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SSM个人博客管理系统(java+ssm+html+jq+jsp+mysql)
项目介绍
管理员角色包含以下功能: 发博客,审核评论,博客增删改查,博客类别增删改查,修改导航,评论增删改查,个人信息修改,登陆页面等功能。
游客角色包含以下功能: 博客首页,查看博客详情,按照日志类别查找,发表评论等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:HTML+CSS+JavaScript+jsp
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| ServletContext application = RequestContextUtils.getWebApplicationContext(request).getServletContext(); Blogger blogger = this.bloggerService.find(); blogger.setPassword(null); application.setAttribute("blogger", blogger); List<BlogType> blogTypeCountList = this.blogTypeService.countList(); application.setAttribute("blogTypeCountList", blogTypeCountList); List<Blog> blogCountList = this.blogService.countList(); application.setAttribute("blogCountList", blogCountList); List<Link> linkList = this.linkService.list(null); application.setAttribute("linkList", linkList); JSONObject result = new JSONObject(); result.put("success", Boolean.valueOf(true)); ResponseUtil.write(response, result); return null; } }
package com.blog.controller; @Controller @RequestMapping({"/comment"}) public class CommentController /* 20: */ { @Resource private CommentService commentService;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| List<BlogType> blogTypeList = this.blogTypeService.list(map); Long total = this.blogTypeService.getTotal(map); JSONObject result = new JSONObject(); JSONArray jsonArray = JSONArray.fromObject(blogTypeList); result.put("rows", jsonArray); result.put("total", total); ResponseUtil.write(response, result); return null; } @RequestMapping({"/save"}) public String save(BlogType blogType, HttpServletResponse response) throws Exception { int resultTotal = 0; if (blogType.getId() == null) { resultTotal = this.blogTypeService.add(blogType).intValue(); } else { resultTotal = this.blogTypeService.update(blogType).intValue(); } JSONObject result = new JSONObject(); if (resultTotal > 0) { result.put("success", Boolean.valueOf(true)); } else { result.put("success", Boolean.valueOf(false)); } ResponseUtil.write(response, result); return null; } @RequestMapping({"/delete"}) public String delete(@RequestParam("ids") String ids, HttpServletResponse response) throws Exception { String[] idsStr = ids.split(","); JSONObject result = new JSONObject(); for (int i = 0; i < idsStr.length; i++) { if (this.blogService.getBlogByTypeId(Integer.valueOf(Integer.parseInt(idsStr[i]))).intValue() > 0) { result.put("exist", "博客类别下有博客,不能删除!"); } else { this.blogTypeService.delete(Integer.valueOf(Integer.parseInt(idsStr[i])));
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| ResponseUtil.write(response, result); return null; } @RequestMapping({"/delete"}) public String delete(@RequestParam("ids") String ids, HttpServletResponse response) throws Exception { String[] idsStr = ids.split(","); for (int i = 0; i < idsStr.length; i++) { this.blogService.delete(Integer.valueOf(Integer.parseInt(idsStr[i]))); this.blogIndex.deleteIndex(idsStr[i]); } JSONObject result = new JSONObject(); result.put("success", Boolean.valueOf(true)); ResponseUtil.write(response, result); return null; } @RequestMapping({"/findById"}) public String findById(@RequestParam("id") String id, HttpServletResponse response) throws Exception { Blog blog = this.blogService.findById(Integer.valueOf(Integer.parseInt(id))); JSONObject jsonObject = JSONObject.fromObject(blog); ResponseUtil.write(response, jsonObject); return null; } }
package com.blog.controller.admin;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| public String save(Blog blog, HttpServletResponse response) throws Exception { int resultTotal = 0; if (blog.getId() == null) { resultTotal = this.blogService.add(blog).intValue(); this.blogIndex.addIndex(blog); } else { resultTotal = this.blogService.update(blog).intValue(); this.blogIndex.updateIndex(blog); } JSONObject result = new JSONObject(); if (resultTotal > 0) { result.put("success", Boolean.valueOf(true)); } else { result.put("success", Boolean.valueOf(false)); } ResponseUtil.write(response, result); return null; } @RequestMapping({"/list"}) public String list(@RequestParam(value="page", required=false) String page, @RequestParam(value="rows", required=false) String rows, Blog s_blog, HttpServletResponse response) throws Exception { PageBean pageBean = new PageBean(Integer.parseInt(page), Integer.parseInt(rows)); Map<String, Object> map = new HashMap(); map.put("title", StringUtil.formatLike(s_blog.getTitle())); map.put("start", Integer.valueOf(pageBean.getStart())); map.put("size", Integer.valueOf(pageBean.getPageSize())); List<Blog> blogList = this.blogService.list(map); Long total = this.blogService.getTotal(map); JSONObject result = new JSONObject(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); JSONArray jsonArray = JSONArray.fromObject(blogList, jsonConfig); result.put("rows", jsonArray); result.put("total", total);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| */ package com.blog.controller.admin; @Controller @RequestMapping({"/admin/link"}) public class LinkAdminController /* 21: */ { @Resource private LinkService linkService; @RequestMapping({"/list"}) public String list(@RequestParam(value="page", required=false) String page, @RequestParam(value="rows", required=false) String rows, HttpServletResponse response) throws Exception { PageBean pageBean = new PageBean(Integer.parseInt(page), Integer.parseInt(rows)); Map<String, Object> map = new HashMap(); map.put("start", Integer.valueOf(pageBean.getStart())); map.put("size", Integer.valueOf(pageBean.getPageSize())); List<Link> linkList = this.linkService.list(map); Long total = this.linkService.getTotal(map); JSONObject result = new JSONObject(); JSONArray jsonArray = JSONArray.fromObject(linkList); result.put("rows", jsonArray); result.put("total", total); ResponseUtil.write(response, result); return null; } @RequestMapping({"/save"}) public String save(Link link, HttpServletResponse response) throws Exception { int resultTotal = 0; if (link.getId() == null) { resultTotal = this.linkService.add(link); } else { resultTotal = this.linkService.update(link); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| @RequestMapping({"/login"}) public String login(Blogger blogger, HttpServletRequest request) { Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(blogger.getUserName(), CryptographyUtil.md5(blogger.getPassword(), "darryl")); try { subject.login(token); return "redirect:/admin/main.jsp"; } catch (Exception e) { e.printStackTrace(); request.setAttribute("blogger", blogger); request.setAttribute("errorInfo", "用户名或密码错误!"); } return "login"; } @RequestMapping({"/aboutMe"}) public ModelAndView aboutMe() throws Exception { ModelAndView mav = new ModelAndView(); mav.addObject("blogger", this.bloggerService.find()); mav.addObject("mainPage", "foreground/blogger/info.jsp"); mav.addObject("pageTitle", "关于博主_Java开源博客系统"); mav.setViewName("mainTemp"); return mav; } }
package com.blog.util;
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=401122512008200mx
https://javayms.pages.dev?id=401122512008200mx