作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目分为前后台,分为普通用户与管理员两个角色,前台为普通用户登录,后台为管理员登录;
管理员角色包含以下功能:
管理员登录,管理员首页,用户管理,作业管理,新闻管理,课程管理,资源管理,互动交流管理等功能。
学生用户角色包含以下功能:
用户首页,查看校园新闻,课程体系查询,资源下载,互动交流,学生用户登录,回复交流帖子,个人中心,提交作业等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
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/8.0等版本均可;
6.是否Maven项目:否;
技术栈
1. 后端:mysql+Spring+hibernate+spring mcv
2. 前端:JSP+CSS+JavaScript+jquery+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目;
3. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/classnet/ 登录
管理员账号/密码:admin/admin
用户账号/密码: user/123456
运行截图
前台用户-用户角色
管理端页面
相关代码
用户管理控制器
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
UserService userService;
@Autowired
HttpServletRequest request;
@GetMapping("/")
public String indexView(
Model model){
model.addAttribute("user",userService.findAll());
return "user";
}
@GetMapping("/add")
public String addView(
Model model){
return "useradd";
}
@GetMapping("/change/{id}")
public String changeView(
Model model, @PathVariable int id){
model.addAttribute("id",id);
return "userchange";
}
@GetMapping("/delete/{id}")
public String deteleView(
Model model, @PathVariable int id){
User user=(User)request.getSession().getAttribute("user");
if (id==user.getId()){
model.addAttribute("msg","不能删除自己");
return "user";
}
userService.deleteUser(id);
model.addAttribute("msg","删除成功");
model.addAttribute("user",userService.findAll());
return "user";
}
@PostMapping("/update/{id}")
public String updateView(
Model model, @PathVariable int id,User user){
User realuser=userService.findByUserId(id);
realuser.setPassword(user.getPassword());
userService.updateUser(realuser);
model.addAttribute("msg","修改成功");
model.addAttribute("user",userService.findAll());
return "user";
}
@PostMapping("/save")
public String updateView(
Model model, User user){
userService.createUser(user);
model.addAttribute("msg","新增成功");
model.addAttribute("user",userService.findAll());
return "user";
}
}
作业管理控制器
@Controller
@RequestMapping("/inventorylog")
public class Inventory_logController {
@Autowired
Inventory_logService InventorylogService;
@Autowired
HttpServletRequest request;
@GetMapping("/")
public String indexView(
Model model){
model.addAttribute("Inventorylog",InventorylogService.findAll());
return "inventorylog";
}
@GetMapping("/add")
public String addView(
Model model){
return "inventorylogadd";
}
@GetMapping("/change/{id}")
public String changeView(
Model model, @PathVariable int id){
model.addAttribute("id",id);
return "inventorylogchange";
}
@GetMapping("/delete/{id}")
public String deteleView(
Model model, @PathVariable int id){
InventorylogService.deleteInventory_log(id);
model.addAttribute("msg","删除成功");
model.addAttribute("user",InventorylogService.findAll());
return "inventorylog";
}
@PostMapping("/update/{id}")
public String updateView(
Model model, @PathVariable int id,Inventory_log Inventorylog){
Inventory_log realuser=InventorylogService.findByInventory_logId(id);
InventorylogService.updateInventory_log(realuser);
model.addAttribute("msg","修改成功");
model.addAttribute("user",InventorylogService.findAll());
return "inventoryloglog";
}
@PostMapping("/save")
public String updateView(
Model model, Inventory_log Inventorylog){
InventorylogService.createInventory_log(Inventorylog);
model.addAttribute("msg","新增成功");
model.addAttribute("user",InventorylogService.findAll());
return "inventorylog";
}
}
如果也想学习本系统,下面领取。关注并回复:091ssh