基于javaweb的SSM新闻发布管理系统(java+ssm+jsp+bootstrap+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

580023352402

590023352402

000023362402

010023362402

020023362402

030023362402

040023362402

基于javaweb的SSM新闻发布管理系统(java+ssm+jsp+bootstrap+jquery+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版本; 6.是否Maven项目:否;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jquery+bootstrap

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中config/db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/News 登录

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

// 去除敏感信息
NewsController.minganInfo(news);

ret.put("type", "success");
ret.put("msg", "修改成功!");
return ret;
}

/**
* 删除新闻
*
* @param id
* @return
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> delete(Long id) {
Map<String, String> ret = new HashMap<String, String>();
if (id == null) {
ret.put("type", "error");
ret.put("msg", "请选择要删除的信息!");
return ret;
}
try {
if (newsService.delete(id) <= 0) {
ret.put("type", "error");
ret.put("msg", "删除失败,请联系管理员!");
return ret;
}
} catch (Exception e) {
ret.put("type", "error");
ret.put("msg", "该新闻下有评论信息,不可删除!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "删除成功!");
return ret;
}

/**
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
52
	return model;
}


/**
* 获取角色列表
* @param page
* @param name
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getList(Page page,
@RequestParam(name="name",required=false,defaultValue="") String name
){
Map<String, Object> ret = new HashMap<String, Object>();
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("name", name);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", roleService.findList(queryMap));
ret.put("total", roleService.getTotal(queryMap));
return ret;
}

/**
* 角色添加
* @param role
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Map<String, String> add(Role role){
Map<String, String> ret = new HashMap<String, String>();
if(role == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的角色信息!");
return ret;
}
if(StringUtils.isEmpty(role.getName())){
ret.put("type", "error");
ret.put("msg", "请填写角色名称!");
return ret;
}
if(roleService.add(role) <= 0){
ret.put("type", "error");
ret.put("msg", "角色添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "角色添加成功!");
return ret;
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
52
53
54

@Autowired
private NewsService newsService;

/**
* 新闻列表页面
*
* @param model
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ModelAndView list(ModelAndView model) {
model.addObject("newsCategoryList", newsCategoryService.findAll());
model.setViewName("news/list");
return model;
}

/**
* 新闻添加页面
*
* @param model
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView add(ModelAndView model) {
model.addObject("newsCategoryList", newsCategoryService.findAll());
model.setViewName("news/add");
return model;
}

/**
* 新闻添加
*
* @param news
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> add(News news) {
Map<String, String> ret = new HashMap<String, String>();
if (news == null) {
ret.put("type", "error");
ret.put("msg", "请填写正确的信息!");
return ret;
}
if (StringUtils.isEmpty(news.getTitle())) {
ret.put("type", "error");
ret.put("msg", "新闻标题不能为空!");
return ret;
}
if (news.getCategoryId() == null) {
ret.put("type", "error");
ret.put("msg", "请选择新闻分类!");
return ret;
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




/**
* 角色role控制器
*
*/
@RequestMapping("/admin/role")
@Controller
public class RoleController {

@Autowired
private RoleService roleService;

@Autowired
private AuthorityService authorityService;

@Autowired
private MenuService menuService;

/**
* 角色列表页面
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.setViewName("/role/list");
return model;
}


/**
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



/**
* 角色role控制器
*
*/
@RequestMapping("/admin/role")
@Controller
public class RoleController {

@Autowired
private RoleService roleService;

@Autowired
private AuthorityService authorityService;

@Autowired
private MenuService menuService;

/**
* 角色列表页面
* @param model
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.GET)
public ModelAndView list(ModelAndView model){
model.setViewName("/role/list");
return model;
}


/**
* 获取角色列表
* @param page
* @param name
* @return
*/
@RequestMapping(value="/list",method=RequestMethod.POST)
@ResponseBody
public Map<String, Object> getList(Page page,
@RequestParam(name="name",required=false,defaultValue="") String name
){
Map<String, Object> ret = new HashMap<String, Object>();
Map<String, Object> queryMap = new HashMap<String, Object>();


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