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







基于javaweb的SSM+Maven个人博客系统(java+ssm+mysql+jsp)
登录:
admin 123456
——————————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 40 41
| @RequestMapping({"/articles/{id}"}) public ModelAndView details(@PathVariable("id") Integer id, HttpServletRequest request) throws Exception { ModelAndView mav = new ModelAndView(); Blog blog = this.blogService.findById(id); String keyWords = blog.getKeyWord(); if (StringUtil.isNotEmpty(keyWords)) { String[] arr = keyWords.split(" "); mav.addObject("keyWords", StringUtil.filterWhite(Arrays.asList(arr))); } else { mav.addObject("keyWords", null); } mav.addObject("blog", blog); blog.setClickHit(Integer.valueOf(blog.getClickHit().intValue() + 1)); this.blogService.update(blog); Map<String, Object> map = new HashMap(); map.put("blogId", blog.getId()); map.put("state", Integer.valueOf(1)); mav.addObject("commentList", this.commentService.list(map)); mav.addObject("pageCode", genUpAndDownPageCode(this.blogService.getLastBlog(id), this.blogService.getNextBlog(id), request.getServletContext().getContextPath())); mav.addObject("mainPage", "foreground/blog/view.jsp"); mav.addObject("pageTitle", blog.getTitle() + "_Java开源博客系统"); mav.setViewName("mainTemp"); return mav; }
@RequestMapping({"/q"}) public ModelAndView search(@RequestParam(value="q", required=false) String q, @RequestParam(value="page", required=false) String page, HttpServletRequest request) throws Exception { if (StringUtil.isEmpty(page)) { page = "1"; } ModelAndView mav = new ModelAndView(); mav.addObject("mainPage", "foreground/blog/result.jsp"); Map<String, Object> map = new HashMap<>(); map.put("title",q);
|
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
| package com.blog.controller.admin; @Controller @RequestMapping({"/admin/comment"}) public class CommentAdminController /* 23: */ { @Resource private CommentService commentService; @RequestMapping({"/list"}) public String list(@RequestParam(value="page", required=false) String page, @RequestParam(value="rows", required=false) String rows, @RequestParam(value="state", required=false) String state, 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())); map.put("state", state); List<Comment> commentList = this.commentService.list(map); Long total = this.commentService.getTotal(map); JSONObject result = new JSONObject(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); JSONArray jsonArray = JSONArray.fromObject(commentList, jsonConfig); result.put("rows", jsonArray); result.put("total", total); ResponseUtil.write(response, result); return null; } @RequestMapping({"/delete"}) public String delete(@RequestParam("ids") String ids, HttpServletResponse response)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| pageCode.append("<li><a href='" + projectContext + "/blog/q.html?page=" + (page.intValue() - 1) + "&q=" + q + "'>上一页</a></li>"); } else { pageCode.append("<li class='disabled'><a href='#'>上一页</a></li>"); } if (page.intValue() < totalPage) { pageCode.append("<li><a href='" + projectContext + "/blog/q.html?page=" + (page.intValue() + 1) + "&q=" + q + "'>下一页</a></li>"); } else { pageCode.append("<li class='disabled'><a href='#'>下一页</a></li>"); } pageCode.append("</ul>"); pageCode.append("</nav>");
return pageCode.toString(); } } /* 1: */ package com.blog.controller.admin; /* 2: */ /* 21: */ /* 22: */ @Controller /* 23: */ @RequestMapping({"/admin/blog"}) /* 24: */ public class BlogAdminController /* 25: */ {
|
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 45 46
| private BlogService blogService; @RequestMapping({"/index"}) public ModelAndView index(@RequestParam(value="page", required=false) String page, @RequestParam(value="typeId", required=false) String typeId, @RequestParam(value="releaseDateStr", required=false) String releaseDateStr, HttpServletRequest request) throws Exception { ModelAndView mav = new ModelAndView(); if (StringUtil.isEmpty(page)) { page = "1"; } PageBean pageBean = new PageBean(Integer.parseInt(page), 10); Map<String, Object> map = new HashMap(); map.put("start", Integer.valueOf(pageBean.getStart())); map.put("size", Integer.valueOf(pageBean.getPageSize())); map.put("typeId", typeId); map.put("releaseDateStr", releaseDateStr); List<Blog> blogList = this.blogService.list(map); for (Blog blog : blogList) { List<String> imagesList = blog.getImagesList(); String blogInfo = blog.getContent(); Document doc = Jsoup.parse(blogInfo); Elements jpgs = doc.select("img[src$=.jpg]"); for (int i = 0; i < jpgs.size(); i++) { Element jpg = (Element)jpgs.get(i); imagesList.add(jpg.toString()); if (i == 2) { break; } } } mav.addObject("blogList", blogList); StringBuffer param = new StringBuffer(); if (StringUtil.isNotEmpty(typeId)) { param.append("typeId=" + typeId + "&"); } if (StringUtil.isNotEmpty(releaseDateStr)) { param.append("releaseDateStr=" + releaseDateStr + "&"); } mav.addObject("pageCode", PageUtil.genPagination(request.getContextPath() + "/index.html", this.blogService.getTotal(map).longValue(), Integer.parseInt(page), 10, param.toString())); mav.addObject("mainPage", "foreground/blog/list.jsp"); mav.addObject("pageTitle", "Java个人博客系统"); mav.setViewName("mainTemp"); return mav; }
|
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
| public ModelAndView download() throws Exception { ModelAndView mav = new ModelAndView(); mav.addObject("mainPage", "foreground/system/download.jsp"); mav.addObject("pageTitle", "本站源码下载页面_Java开源博客系统"); mav.setViewName("mainTemp"); return mav; } }
package com.blog.controller.admin; @Controller @RequestMapping({"/admin/comment"}) public class CommentAdminController /* 23: */ { @Resource
|
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
| pageCode.append("<li class='disabled'><a href='#'>上一页</a></li>"); } if (page.intValue() < totalPage) { pageCode.append("<li><a href='" + projectContext + "/blog/q.html?page=" + (page.intValue() + 1) + "&q=" + q + "'>下一页</a></li>"); } else { pageCode.append("<li class='disabled'><a href='#'>下一页</a></li>"); } pageCode.append("</ul>"); pageCode.append("</nav>");
return pageCode.toString(); } } /* 1: */ package com.blog.controller.admin; /* 2: */ /* 21: */ /* 22: */ @Controller /* 23: */ @RequestMapping({"/admin/blog"}) /* 24: */ public class BlogAdminController /* 25: */ { /* 26: */ @Resource /* 27: */ private BlogService blogService; /* 28: 40 */ private BlogIndex blogIndex = new BlogIndex(); /* 29: */ /* 30: */ @RequestMapping({"/save"}) /* 31: */ public String save(Blog blog, HttpServletResponse response) /* 32: */ throws Exception /* 33: */ { /* 34: 51 */ int resultTotal = 0; /* 35: 52 */ if (blog.getId() == null)
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=502023512309201fi
https://javayms.pages.dev?id=502023512309201fi