基于javaweb的家教管理系统(java+ssm+mybatis+mysql+jsp)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+jsp的家教管理系统(java+SSM+MyBatis+MySQL+Maven+Jsp)
该系统分为前台和后台
前台功能有:登录、注册、查看学员、查看教师、个人中心等。
后台功能有:用户管理、学员管理、教师管理、审核管理、公告管理、新闻管理、简历管理等。前台注册分为学员和教师两个角色,学员负责找家教教师、发布需求。教师制作简历供学员选择、联系学员。类似于兼职系统。
本项目如环境一致包运行调试,如有问题可以联系我,右侧有我的联系方式
运行环境:JDK1.8、Mysql5.X、Tomcat7.0/8.5、Maven3.5/3.6、Eclipse
用户管理控制层:
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = “/users”, produces = “text/plain;charset=utf-8”)
public class UsersController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private UsersService usersService;
// 准备添加数据
@RequestMapping(“/createUsers”)
public String createUsers() {
return “admin/addusers”;
// 添加数据
@RequestMapping(“/addUsers”)
public String addUsers(Users users) {
this.usersService.insertUsers(users);
return “redirect:/users/createUsers”;
// 通过主键删除数据
@RequestMapping(“/deleteUsers”)
public String deleteUsers(String id) {
this.usersService.deleteUsers(id);
return “redirect:/users/getAllUsers”;
// 批量删除数据
@RequestMapping(“/deleteUsersByIds”)
public String deleteUsersByIds() {
String[] ids = this.getRequest().getParameterValues(“usersid”);
for (String usersid : ids) {
this.usersService.deleteUsers(usersid);
return “redirect:/users/getAllUsers”;
// 更新数据
@RequestMapping(“/updateUsers”)
public String updateUsers(Users users) {
this.usersService.updateUsers(users);
return “redirect:/users/getAllUsers”;
// 显示全部数据
@RequestMapping(“/getAllUsers”)
public String getAllUsers(String number) {
List usersList = this.usersService.getAllUsers();
PageHelper.getPage(usersList, “users”, null, null, 10, number, this.getRequest(), null);
return “admin/listusers”;
// 按条件查询数据 (模糊查询)
@RequestMapping(“/queryUsersByCond”)
public String queryUsersByCond(String cond, String name, String number) {
Users users = new Users();
if (cond != null) {
if (“username”.equals(cond)) {
users.setUsername(name);
if (“password”.equals(cond)) {
users.setPassword(name);
if (“realname”.equals(cond)) {
users.setRealname(name);
if (“sex”.equals(cond)) {
users.setSex(name);
if (“birthday”.equals(cond)) {
users.setBirthday(name);
if (“contact”.equals(cond)) {
users.setContact(name);
if (“regdate”.equals(cond)) {
users.setRegdate(name);
List nameList = new ArrayList();
List valueList = new ArrayList();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.usersService.getUsersByLike(users), “users”, nameList, valueList, 10, number, this.getRequest(), “query”);
name = null;
cond = null;
return “admin/queryusers”;
// 按主键查询数据
@RequestMapping(“/getUsersById”)
public String getUsersById(String id) {
Users users = this.usersService.getUsersById(id);
this.getRequest().setAttribute(“users”, users);
return “admin/editusers”;
public UsersService getUsersService() {
return usersService;
public void setUsersService(UsersService usersService) {
this.usersService = usersService;
订单管理控制层:
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = “/orders”, produces = “text/plain;charset=utf-8”)
public class OrdersController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private OrdersService ordersService;
@Autowired
@Resource
private UsersService usersService;
// 准备添加数据
@RequestMapping(“/createOrders”)
public String createOrders() {
List usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute(“usersList”, usersList);
return “admin/addorders”;
// 添加数据
@RequestMapping(“/addOrders”)
public String addOrders(Orders orders) {
this.ordersService.insertOrders(orders);
return “redirect:/orders/createOrders”;
// 通过主键删除数据
@RequestMapping(“/deleteOrders”)
public String deleteOrders(String id) {
this.ordersService.deleteOrders(id);
return “redirect:/orders/getAllOrders”;
// 批量删除数据
@RequestMapping(“/deleteOrdersByIds”)
public String deleteOrdersByIds() {
String[] ids = this.getRequest().getParameterValues(“ordersid”);
for (String ordersid : ids) {
this.ordersService.deleteOrders(ordersid);
return “redirect:/orders/getAllOrders”;
// 更新数据
@RequestMapping(“/updateOrders”)
public String updateOrders(Orders orders) {
this.ordersService.updateOrders(orders);
return “redirect:/orders/getAllOrders”;
// 显示全部数据
@RequestMapping(“/getAllOrders”)
public String getAllOrders(String number) {
List ordersList = this.ordersService.getAllOrders();
PageHelper.getPage(ordersList, “orders”, null, null, 10, number, this.getRequest(), null);
return “admin/listorders”;
// 按条件查询数据 (模糊查询)
@RequestMapping(“/queryOrdersByCond”)
public String queryOrdersByCond(String cond, String name, String number) {
Orders orders = new Orders();
if (cond != null) {
if (“ordercode”.equals(cond)) {
orders.setOrdercode(name);
if (“usersid”.equals(cond)) {
orders.setUsersid(name);
if (“total”.equals(cond)) {
orders.setTotal(name);
if (“addtime”.equals(cond)) {
orders.setAddtime(name);
if (“status”.equals(cond)) {
orders.setStatus(name);
if (“address”.equals(cond)) {
orders.setAddress(name);
if (“contact”.equals(cond)) {
orders.setContact(name);
if (“workdate”.equals(cond)) {
orders.setWorkdate(name);
if (“worktime”.equals(cond)) {
orders.setWorktime(name);
List nameList = new ArrayList();
List valueList = new ArrayList();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.ordersService.getOrdersByLike(orders), “orders”, nameList, valueList, 10, number, this.getRequest(), “query”);
name = null;
cond = null;
return “admin/queryorders”;
// 按主键查询数据
@RequestMapping(“/getOrdersById”)
public String getOrdersById(String id) {
Orders orders = this.ordersService.getOrdersById(id);
this.getRequest().setAttribute(“orders”, orders);
List usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute(“usersList”, usersList);
return “admin/editorders”;
public OrdersService getOrdersService() {
return ordersService;
public void setOrdersService(OrdersService ordersService) {
this.ordersService = ordersService;
管理员管理控制层:
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = “/admin”, produces = “text/plain;charset=utf-8”)
public class AdminController extends BaseController {
// 注入Service 由于标签的存在 所以不需要getter setter
@Autowired
@Resource
private AdminService adminService;
// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
@RequestMapping(“/login”)
public String login() {
String username = this.getRequest().getParameter(“username”);
String password = this.getRequest().getParameter(“password”);
Admin adminpojo = new Admin();
adminpojo.setUsername(username);
List adminlist = this.adminService.getAdminByCond(adminpojo);
if (adminlist.size() == 0) {
this.getRequest().setAttribute(“message”, “用户名不存在”);
return “admin/index”;
} else {
Admin admin = adminlist.get(0);
if (password.equals(admin.getPassword())) {
this.getSession().setAttribute(“adminid”, admin.getAdminid());
this.getSession().setAttribute(“adminname”, admin.getUsername());
this.getSession().setAttribute(“realname”, admin.getRealname());
this.getSession().setAttribute(“role”, admin.getRole());
} else {
this.getRequest().setAttribute(“message”, “密码错误”);
return “admin/index”;
return “admin/main”;
// 修改密码
@RequestMapping(“/editpwd”)
public String editpwd() {
String adminid = (String) this.getSession().getAttribute(“adminid”);
String password = this.getRequest().getParameter(“password”);
String repassword = this.getRequest().getParameter(“repassword”);
Admin admin = this.adminService.getAdminById(adminid);
if (password.equals(admin.getPassword())) {
admin.setPassword(repassword);
this.adminService.updateAdmin(admin);
} else {
this.getRequest().setAttribute(“message”, “旧密码错误”);
return “admin/editpwd”;
// 管理员退出登录
@RequestMapping(“/exit”)
public String exit() {
this.getSession().removeAttribute(“adminid”);
this.getSession().removeAttribute(“adminname”);
this.getSession().removeAttribute(“realname”);
this.getSession().removeAttribute(“role”);
return “admin/index”;
// 准备添加数据
@RequestMapping(“/createAdmin”)
public String createAdmin() {
return “admin/addadmin”;
// 添加数据
@RequestMapping(“/addAdmin”)
public String addAdmin(Admin admin) {
admin.setAddtime(VeDate.getStringDateShort());
this.adminService.insertAdmin(admin);
return “redirect:/admin/createAdmin”;
// 通过主键删除数据
@RequestMapping(“/deleteAdmin”)
public String deleteAdmin(String id) {
this.adminService.deleteAdmin(id);
return “redirect:/admin/getAllAdmin”;
// 批量删除数据
@RequestMapping(“/deleteAdminByIds”)
public String deleteAdminByIds() {
String[] ids = this.getRequest().getParameterValues(“adminid”);
for (String adminid : ids) {
this.adminService.deleteAdmin(adminid);
return “redirect:/admin/getAllAdmin”;
// 更新数据
@RequestMapping(“/updateAdmin”)
public String updateAdmin(Admin admin) {
this.adminService.updateAdmin(admin);
return “redirect:/admin/getAllAdmin”;
// 显示全部数据
@RequestMapping(“/getAllAdmin”)
public String getAllAdmin(String number) {
List adminList = this.adminService.getAllAdmin();
PageHelper.getPage(adminList, “admin”, null, null, 10, number, this.getRequest(), null);
return “admin/listadmin”;
// 按条件查询数据 (模糊查询)
@RequestMapping(“/queryAdminByCond”)
public String queryAdminByCond(String cond, String name, String number) {
Admin admin = new Admin();
if (cond != null) {
if (“username”.equals(cond)) {
admin.setUsername(name);
if (“password”.equals(cond)) {
admin.setPassword(name);
if (“realname”.equals(cond)) {
admin.setRealname(name);
if (“contact”.equals(cond)) {
admin.setContact(name);
if (“role”.equals(cond)) {
admin.setRole(name);
if (“addtime”.equals(cond)) {
admin.setAddtime(name);
List nameList = new ArrayList();
List valueList = new ArrayList();
nameList.add(cond);
valueList.add(name);
PageHelper.getPage(this.adminService.getAdminByLike(admin), “admin”, nameList, valueList, 10, number, this.getRequest(), “query”);
name = null;
cond = null;
return “admin/queryadmin”;
// 按主键查询数据
@RequestMapping(“/getAdminById”)
public String getAdminById(String id) {
Admin admin = this.adminService.getAdminById(id);
this.getRequest().setAttribute(“admin”, admin);
return “admin/editadmin”;
public AdminService getAdminService() {
return adminService;
public void setAdminService(AdminService adminService) {
this.adminService = adminService;