基于javaweb的SSM个人博客系统(java+ssm+mysql+jsp)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

041823562708

051823562708

061823562708

071823562708

091823562708

基于javaweb的SSM个人博客系统(java+ssm+mysql+jsp)

前台访问地址:http://localhost:8080/boke/index.do
zhangsan 123456
lisi 123456
wangwu 123456
zhaoliu 123456
sunqi 123456

后台访问地址:http://localhost:8080/boke/admin/login.jsp
admin 123456

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
/**
* 保存新增管理员信息
*
* @param tadmin
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/tadmin_add")
public String add(Tadmin tadmin, HttpServletRequest request)
throws Exception {
// 保存到数据库
tadminService.insertTadmin(tadmin);
return "redirect:tadmin_list.action";
}

/**
* 跳转到更新管理员信息界面
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/tadmin_toUpdate")
public String toUpdate(HttpServletRequest request) throws Exception {
int id = Integer.parseInt(request.getParameter("id"));
// 根据ID查询出需要更新的记录
Tadmin tadmin = tadminService.queryTadminById(id);
request.setAttribute("tadmin", tadmin);
return "/admin/tadmin/tadmin_update.jsp";
}

/**
* 更新管理员信息
*
* @param tadmin
* @param request
* @return
* @throws Exception
*/
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
47
48
49
50
51
/**
* 保存新增分类
*
* @param blogtype
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/blogtype_add")
public String add(Blogtype blogtype, HttpServletRequest request)
throws Exception {
// 保存到数据库
blogtypeService.insertBlogtype(blogtype);
return "redirect:blogtype_list.action";
}

/**
* 跳转到更新分类界面
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/blogtype_toUpdate")
public String toUpdate(HttpServletRequest request) throws Exception {
int id = Integer.parseInt(request.getParameter("id"));
// 根据ID查询出需要更新的记录
Blogtype blogtype = blogtypeService.queryBlogtypeById(id);
request.setAttribute("blogtype", blogtype);
return "/admin/blogtype/blogtype_update.jsp";
}

/**
* 更新分类
*
* @param blogtype
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/blogtype_update")
public String update(Blogtype blogtype, HttpServletRequest request)
throws Exception {
// 更新数据库
blogtypeService.updateBlogtype(blogtype);
return "redirect:blogtype_list.action";
}

/**
* 删除分类
*
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 = blogTypeService.getBlogTypeData(bid);
request.getSession().setAttribute("blogTypeList", blogTypeList);

Blogger blogger = bloggerService.queryBloggerById(bid);
request.getSession().setAttribute("blogger", blogger);

//判断是否点赞
boolean favbool=false;
if(request.getSession().getAttribute("user")!=null){
Blogger user = (Blogger) request.getSession().getAttribute("user");
Fav fav = new Fav();
fav.setBzid(bid);
fav.setUid(user.getId());
List<Fav> fs = favService.queryFavList(fav, null);
if(fs!=null&&fs.size()>0){
favbool = true;
}
}


modelAndView.addObject("favbool", favbool);

return modelAndView;

}

/**
* @Description 请求主页
* @return
*/
@RequestMapping("/")
public String home(HttpServletRequest request) throws Exception {

return "/index";

}
}



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
47
48
49
50


/**
* 标签Controller业务控制类
*/
@Controller
public class TagController {
/**
* 注入Service
*/
@Autowired
private TagService tagService;

/**
* 标签列表
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/tag_list")
public String list(HttpServletRequest request) throws Exception {
/**
* 获取分页参数
*/
int offset = 0; // 记录偏移量
int counts = 0; // 总记录数
try {
offset = Integer.parseInt(request.getParameter("pager.offset"));
} catch (Exception e) {
}
PageBean page = new PageBean(offset);
Tag tag = new Tag();
// 查询记录总数
counts = tagService.getCount(tag);
// 获取当前页记录
List tagList = tagService.queryTagList(tag, page);
request.setAttribute("list", tagList);
// 将分页相关参数放到request中
request.setAttribute("itemSize", counts);
int page_count = counts % PageBean.PAGE_IETM == 0 ? counts
/ PageBean.PAGE_IETM : counts / PageBean.PAGE_IETM + 1;
request.setAttribute("pageItem", PageBean.PAGE_IETM);
request.setAttribute("pageTotal", page_count);
return "/admin/tag/tag_list.jsp";
}

/**
* 跳转到新增标签界面
*
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
			throws Exception {
// 更新数据库
blogService.updateBlog(blog);
return "redirect:blog_list.action";
}

/**
* 删除博客
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/blog_delete")
public String delete(HttpServletRequest request) throws Exception {
// 根据id删除数据库记录
int id = Integer.parseInt(request.getParameter("id"));
blogService.deleteBlog(id);
return "redirect:blog_list.action";
}

/**
* 查看博客详情
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/blog_toView")
public String toView(HttpServletRequest request) throws Exception {
int id = Integer.parseInt(request.getParameter("id"));
// 根据ID查询出记录放到request中,到前台jsp界面显示
Blog blog = new Blog();
blog.setId(id);
List<Blog> list = blogService.queryBlogList(blog, null);
blog = list.get(0);
request.setAttribute("blog", blog);
return "/admin/blog/blog_view.jsp";
}
}




项目链接:
https://javayms.github.io?id=031823562708201cc
https://javayms.pages.dev?id=031823562708201cc