基于javaweb+mysql的springboot+mybatis在线美食网站系统(java+ssm+jsp+mysql+maven)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot+MyBatis在线美食网站系统(java+ssm+jsp+mysql+maven)
一、项目简述
功能:用户的注册登录,美食浏览,美食文化,收藏百 科,趣味问答,食谱等等功能等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等。
@GetMapping("/UserManageSy")
public String CommentManageSy(Model model) {
List<User> users = userService.findAllUser();
model.addAttribute("users", users);
return "usermanagesy";
}
@GetMapping("/userDel")
public String userDel(String name) {
boolean ret = userService.delUserByName(name);
return "redirect:UserManageSy";
}
@GetMapping("/userEditByManager")
public String userEdit(String username, Model model) {
User user = userService.findUserByName(username);
model.addAttribute("userE", user);
return "useredit";
}
@PostMapping("/userEditByManager")
public String doUserEdit(User user) {
boolean ret = userService.updateuser(user);
if (ret) {
return "redirect:UserManageSy";
} else {
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
@GetMapping("/commentDel")
public String CommentManageSy(String comment) {
boolean ret=foodinfoService.commentDel(comment);
return "redirect:CommentManageSy";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class FoodController {
public FoodService foodService;
@Autowired
public void setFoodService(FoodService foodService) {
this.foodService = foodService;
}
@GetMapping("/sy")
public String tosy() {
return "sy";
}
@GetMapping("/foodlist")
public String findAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> pageInfo = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", pageInfo);
return "foodlist";
}
@GetMapping("/adminfoodlist")
public String adminfindAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> a = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", a);
return "adminsy";
}
@Controller
public class FoodInfoController {
public FoodInfoService foodinfoService;
@Autowired
public void setFoodInfoService(FoodInfoService foodinfoService) {
this.foodinfoService = foodinfoService;
}
@GetMapping("/findinfo")
public String findFoodinfoByName(String name, Model model) {
Food food = foodinfoService.findFoodByName(name);
model.addAttribute("food", food);
return "make";
}
@GetMapping("/Collect")
public String insertFoodByName(String userName, String foodName, String date, Model model, HttpSession session) {
OrderedFood orderedFood = foodinfoService.findCollectInfoByFoodName(foodName);
if (orderedFood != null) {
model.addAttribute("msg", "该美食已收藏!");
} else {
boolean ret = foodinfoService.insertFoodByName(userName, foodName, date);
if (ret) {
model.addAttribute("msg", "收藏成功!");
} else {
model.addAttribute("msg", "收藏失败!");
}
}
Food food = foodinfoService.findFoodByName(foodName);
session.setAttribute("food", food);
return "make";
}
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
model.addAttribute("msg", "登入成功!开启美食冲浪!");
return "usersy";
} else {
model.addAttribute("msg", "用户名或者密码错误");
return "login";
}
}
@GetMapping("/exit")
public String exit(HttpSession session) {
session.removeAttribute("user");
return "redirect:login";
}
@GetMapping("/register")
public String toRegister() {
return "register";
}
@PostMapping("/register")
public String toRegister(User user, Model model) {
boolean ret = userService.addUser(user);
if (ret) {
model.addAttribute("msg", "注册成功!请使用账号登录!");
return "sy";
} else {
model.addAttribute("msg", "注册失败!");
return "sy";
}
}
@GetMapping("/edituser")
public String toEdit(String username, Model model) {
User user = userService.findUserByName(username);
model.addAttribute("u", user);
return "usercenter";
}
return "usermanagesy";
}
@GetMapping("/userDel")
public String userDel(String name) {
boolean ret = userService.delUserByName(name);
return "redirect:UserManageSy";
}
@GetMapping("/userEditByManager")
public String userEdit(String username, Model model) {
User user = userService.findUserByName(username);
model.addAttribute("userE", user);
return "useredit";
}
@PostMapping("/userEditByManager")
public String doUserEdit(User user) {
boolean ret = userService.updateuser(user);
if (ret) {
return "redirect:UserManageSy";
} else {
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
@GetMapping("/exit")
public String exit(HttpSession session) {
session.removeAttribute("user");
return "redirect:login";
}
@GetMapping("/register")
public String toRegister() {
return "register";
}
@PostMapping("/register")
public String toRegister(User user, Model model) {
boolean ret = userService.addUser(user);
if (ret) {
model.addAttribute("msg", "注册成功!请使用账号登录!");
return "sy";
} else {
model.addAttribute("msg", "注册失败!");
return "sy";
}
}
@GetMapping("/edituser")
public String toEdit(String username, Model model) {
User user = userService.findUserByName(username);
model.addAttribute("u", user);
return "usercenter";
}
@PostMapping("/edituser")
public String doEdit(User user, Model model) {
boolean ret = userService.updateuser(user);
System.out.println(ret);
if (ret) {
return "redirect:usersy";
} else {
return "usercenter";
}
}
@GetMapping("/UserManageSy")
public String CommentManageSy(Model model) {
List<User> users = userService.findAllUser();
model.addAttribute("users", users);
return "usermanagesy";
}
@GetMapping("/userDel")
this.foodinfoService = foodinfoService;
}
@GetMapping("/findinfo")
public String findFoodinfoByName(String name, Model model) {
Food food = foodinfoService.findFoodByName(name);
model.addAttribute("food", food);
return "make";
}
@GetMapping("/Collect")
public String insertFoodByName(String userName, String foodName, String date, Model model, HttpSession session) {
OrderedFood orderedFood = foodinfoService.findCollectInfoByFoodName(foodName);
if (orderedFood != null) {
model.addAttribute("msg", "该美食已收藏!");
} else {
boolean ret = foodinfoService.insertFoodByName(userName, foodName, date);
if (ret) {
model.addAttribute("msg", "收藏成功!");
} else {
model.addAttribute("msg", "收藏失败!");
}
}
Food food = foodinfoService.findFoodByName(foodName);
session.setAttribute("food", food);
return "make";
}
@GetMapping("/CollectInfo")
public String findCollectInfoByName(String name, Model model) {
List<OrderedFood> orderedFoods = foodinfoService.findCollectInfoByName(name);
model.addAttribute("orderedFoods", orderedFoods);
return "collect";
}
@GetMapping("/collectDel")
public String del(String food_name, String user_name, Model model) {
boolean ret = foodinfoService.delCollect(food_name, user_name);
List<OrderedFood> orderedFoods = foodinfoService.findCollectInfoByName(user_name);
model.addAttribute("orderedFoods", orderedFoods);
return "collect";
}
@GetMapping("/Comment")
public String Comment(String name,Model model) {
List<Comment> comments=foodinfoService.findAllComments();
model.addAttribute("comments",comments);
return "comment";
}
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
@GetMapping("/adminlogin")
public String toLoginadmin() {
return "adminlogin";
}
@PostMapping("/adminlogin")
public String adminlogin(Admin admin, HttpSession session, Model model) {
Admin r = adminService.findAdmin(admin);
System.out.println(admin.getAdminname());
System.out.println(admin.getAdminpassword());
System.out.println(r);
if (r != null) {
session.setAttribute("admin", r);
return "redirect:adminfoodlist";
} else {
model.addAttribute("msg","用户名或者密码错误");
return "adminlogin";
}
}
@GetMapping("/exitadmin")
public String exitadmin(HttpSession session) {
PageInfo<Food> info = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", info);
return "foodinfolist";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
model.addAttribute("msg", "登入成功!开启美食冲浪!");
return "usersy";
} else {
model.addAttribute("msg", "用户名或者密码错误");
@Controller
public class FoodInfoController {
public FoodInfoService foodinfoService;
@Autowired
public void setFoodInfoService(FoodInfoService foodinfoService) {
this.foodinfoService = foodinfoService;
}
@GetMapping("/findinfo")
public String findFoodinfoByName(String name, Model model) {
Food food = foodinfoService.findFoodByName(name);
model.addAttribute("food", food);
return "make";
}
@GetMapping("/Collect")
public String insertFoodByName(String userName, String foodName, String date, Model model, HttpSession session) {
OrderedFood orderedFood = foodinfoService.findCollectInfoByFoodName(foodName);
if (orderedFood != null) {
model.addAttribute("msg", "该美食已收藏!");
} else {
boolean ret = foodinfoService.insertFoodByName(userName, foodName, date);
if (ret) {
model.addAttribute("msg", "收藏成功!");
} else {
model.addAttribute("msg", "收藏失败!");
}
}
Food food = foodinfoService.findFoodByName(foodName);
session.setAttribute("food", food);
return "make";
}
@GetMapping("/CollectInfo")
public String findCollectInfoByName(String name, Model model) {
List<OrderedFood> orderedFoods = foodinfoService.findCollectInfoByName(name);
model.addAttribute("orderedFoods", orderedFoods);
return "collect";
}
@GetMapping("/collectDel")
public String del(String food_name, String user_name, Model model) {
boolean ret = foodinfoService.delCollect(food_name, user_name);
}
@GetMapping("/userEditByManager")
public String userEdit(String username, Model model) {
User user = userService.findUserByName(username);
model.addAttribute("userE", user);
return "useredit";
}
@PostMapping("/userEditByManager")
public String doUserEdit(User user) {
boolean ret = userService.updateuser(user);
if (ret) {
return "redirect:UserManageSy";
} else {
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
/**
*/
@Controller
public class FoodController {
public FoodService foodService;
@Autowired
public void setFoodService(FoodService foodService) {
this.foodService = foodService;
}
@GetMapping("/sy")
public String tosy() {
return "sy";
}
@GetMapping("/foodlist")
public String findAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> pageInfo = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", pageInfo);
return "foodlist";
}
@GetMapping("/adminfoodlist")
public String adminfindAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> a = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", a);
return "adminsy";
}
@GetMapping("/find")
public String findFoodByName(String name, Model model) {
List<Food> food = foodService.vagueFindByName(name);
model.addAttribute("food", food);
return "findlist";
}
@GetMapping("add")
public String toadd() {
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
model.addAttribute("msg", "登入成功!开启美食冲浪!");
return "usersy";
} else {
model.addAttribute("msg", "用户名或者密码错误");
return "login";
}
}
@GetMapping("/exit")
public String exit(HttpSession session) {
@GetMapping("/editinfo")
public String toinfoEdit(String name, Model model) {
Food food = foodService.findFoodByName(name);
System.out.println(food);
model.addAttribute("f", food);
return "infoedit";
}
@PostMapping("/editinfo")
public String doinfoEdit(Food food) {
boolean ret = foodService.updateinfo(food);
System.out.println(ret);
if (ret) {
return "redirect:foodinfolist";
} else {
return "editinfo";
}
}
@GetMapping("/foodinfolist")
public String cultureAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> info = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", info);
return "foodinfolist";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
model.addAttribute("msg", "登入成功!开启美食冲浪!");
return "usersy";
} else {
model.addAttribute("msg", "用户名或者密码错误");
return "login";
}
}
@GetMapping("/exit")
public String exit(HttpSession session) {
session.removeAttribute("user");
return "redirect:login";
}
@GetMapping("/register")
public String toRegister() {
return "register";
}
@PostMapping("/register")
public String toRegister(User user, Model model) {
boolean ret = userService.addUser(user);
if (ret) {
model.addAttribute("msg", "注册成功!请使用账号登录!");
@GetMapping("/foodDel")
public String del(String name) {
boolean ret = foodService.delfood(name);
return "redirect:adminfoodlist";
}
@GetMapping("/edit")
public String toEdit(String name, Model model) {
Food food = foodService.findFoodByName(name);
System.out.println(food);
model.addAttribute("f", food);
return "edit";
}
@PostMapping("/edit")
public String doEdit(Food food) {
boolean ret = foodService.updateFood(food);
System.out.println(ret);
if (ret) {
return "redirect:adminfoodlist";
} else {
return "edit";
}
}
@GetMapping("/editinfo")
public String toinfoEdit(String name, Model model) {
Food food = foodService.findFoodByName(name);
System.out.println(food);
model.addAttribute("f", food);
return "infoedit";
}
@PostMapping("/editinfo")
public String doinfoEdit(Food food) {
boolean ret = foodService.updateinfo(food);
System.out.println(ret);
if (ret) {
return "redirect:foodinfolist";
} else {
return "editinfo";
}
}
@GetMapping("/foodinfolist")
public String cultureAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> info = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", info);
return "foodinfolist";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
model.addAttribute("msg", "登入成功!开启美食冲浪!");
return "usersy";
} else {
model.addAttribute("msg", "用户名或者密码错误");
return "login";
}
}
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
@GetMapping("/adminlogin")
public String toLoginadmin() {
return "adminlogin";
}
@PostMapping("/adminlogin")
public String adminlogin(Admin admin, HttpSession session, Model model) {
Admin r = adminService.findAdmin(admin);
public String doinfoEdit(Food food) {
boolean ret = foodService.updateinfo(food);
System.out.println(ret);
if (ret) {
return "redirect:foodinfolist";
} else {
return "editinfo";
}
}
@GetMapping("/foodinfolist")
public String cultureAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> info = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", info);
return "foodinfolist";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "editinfo";
}
}
@GetMapping("/foodinfolist")
public String cultureAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> info = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", info);
return "foodinfolist";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
User ret = userService.findUser(user);
if (ret != null) {
session.setAttribute("user", ret);
model.addAttribute("msg", "登入成功!开启美食冲浪!");
return "usersy";
} else {
model.addAttribute("msg", "用户名或者密码错误");
return "login";
}
}
@GetMapping("/exit")
public String exit(HttpSession session) {
session.removeAttribute("user");
return "redirect:login";
}
@GetMapping("/register")
public String toRegister() {
return "register";
}
@PostMapping("/register")
public String toRegister(User user, Model model) {
boolean ret = userService.addUser(user);
if (ret) {
model.addAttribute("msg", "注册成功!请使用账号登录!");
return "sy";
} else {
model.addAttribute("msg", "注册失败!");
return "sy";
}
}
@GetMapping("/foodinfolist")
public String cultureAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> info = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", info);
return "foodinfolist";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class UserController {
public UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@GetMapping("/login")
public String toLogin() {
return "login";
}
@GetMapping("/usersy")
public String toUsersy() {
return "usersy";
}
@PostMapping("/login")
public String login(User user, HttpSession session, Model model) {
@GetMapping("/CommentManageSy")
public String CommentManageSy(Model model) {
List<Comment> comments=foodinfoService.findAllComments();
model.addAttribute("comments",comments);
return "commentmanagesy";
}
@GetMapping("/commentDel")
public String CommentManageSy(String comment) {
boolean ret=foodinfoService.commentDel(comment);
return "redirect:CommentManageSy";
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class FoodController {
public FoodService foodService;
@Autowired
public void setFoodService(FoodService foodService) {
this.foodService = foodService;
}
@GetMapping("/sy")
public String tosy() {
return "sy";
}
@GetMapping("/foodlist")
public String findAll(Model model, @RequestParam(required = false, defaultValue = "1") int pageNum, @RequestParam(required = false, defaultValue = "8") int pageSize) {
PageInfo<Food> pageInfo = foodService.findAllFoods(pageNum, pageSize);
model.addAttribute("pageInfo", pageInfo);
return "foodlist";
}
@GetMapping("/adminfoodlist")
if (ret) {
return "redirect:UserManageSy";
} else {
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
@GetMapping("/adminlogin")
public String toLoginadmin() {
return "adminlogin";
}
@PostMapping("/adminlogin")
public String adminlogin(Admin admin, HttpSession session, Model model) {
Admin r = adminService.findAdmin(admin);
@PostMapping("/userEditByManager")
public String doUserEdit(User user) {
boolean ret = userService.updateuser(user);
if (ret) {
return "redirect:UserManageSy";
} else {
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
@GetMapping("/adminlogin")
public String toLoginadmin() {
return "adminlogin";
}
@GetMapping("/userEditByManager")
public String userEdit(String username, Model model) {
User user = userService.findUserByName(username);
model.addAttribute("userE", user);
return "useredit";
}
@PostMapping("/userEditByManager")
public String doUserEdit(User user) {
boolean ret = userService.updateuser(user);
if (ret) {
return "redirect:UserManageSy";
} else {
return "useredit";
}
}
}
package com.food.foodweb.controller;
/**
*/
@Controller
public class AdminController {
public AdminService adminService;
@Autowired
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
@GetMapping("/adminlogin")
public String toLoginadmin() {
return "adminlogin";
}