基于javaweb+mysql的ssm农家乐管理系统(java+ssm+vue+elementui+axios+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM农家乐管理系统(java+ssm+vue+elementui+axios+mysql)
项目介绍
基于SSM的农家乐管理系统
角色:管理员、用户
本课程设计了农家乐管理系统 ,
用户可以此系统实现美食信息、住宿信息、活动信息、活动报名、客房预订等信息,管理员通过后台会对此美食信息进行审核,管理员在还可以进行首页、个人中心、农家乐管理、美食信息管理、住宿信息管理、活动信息管理、用户管理、活动报名管理、客房预订管理、用户评价管理、论坛交流、管理员管理、系统管理,前台首页;首页、农家乐、美食信息、住宿信息、活动信息、论坛交流、系统公告、个人中心、后台管理、在线客服,用户;首页、个人中心、活动报名管理、客房预订管理、用户评价管理、我的收藏管理等操作。
环境需要
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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:ElementUI+Vue
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目; 3. 将项目中db.xml配置文件中的数据库配置改为自己的配置,然后运行;
e.printStackTrace();
} else if ("scenic".equals(method)) {// 列表
try {
JSONArray scenic = dao.findJSONArray("select * from scenic");
service.outWrite(out, scenic.toString());
} catch (SQLException e) {
e.printStackTrace();
} else if ("searchScenic".equals(method)) {// 查询
try {
JSONArray scenic = dao
.findJSONArray("select * from scenic where sce_name like '%" + sce.getSceName() + "%'");
JSONObject user = null;
try {
user = dao.findJSONObject("select * from users where uname = ? and password = ?", params);
System.out.println(user);
System.out.println(user.get("uname"));
System.out.println(user.get("utype"));
request.getSession().setAttribute("uname", user.get("uname"));
request.getSession().setAttribute("utype", user.get("utype"));
} catch (SQLException e) {
e.printStackTrace();
JSONObject user = null;
try {
user = dao.findJSONObject("select * from users where uname = ? and password = ?", params);
System.out.println(user);
System.out.println(user.get("uname"));
System.out.println(user.get("utype"));
request.getSession().setAttribute("uname", user.get("uname"));
request.getSession().setAttribute("utype", user.get("utype"));
} catch (SQLException e) {
e.printStackTrace();
} finally {
request.setAttribute("food", food);
request.getRequestDispatcher("food-list.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
} else if ("detailFood".equals(method)) {// 美食详情
try {
JSONObject food = dao.findJSONObject("select * from food where foo_id=?", foo.getFooId());
request.setAttribute("food", food);
request.getRequestDispatcher("food-detail.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
登陆管理控制层:
String savepath = service.imagepath(part1);
img_url = savepath;
} else {
img_url = sce.getImgUrl();
Object[] params = { sce.getSceName(), img_url, sce.getAddress(), sce.getDescription(), sce.getSceId() };
try {
int i = dao.update("update scenic set sce_name = ?,img_url=?,address=?,description=? where sce_id=?",
params);
if (i > 0) {
response.sendRedirect("ScenicServlet?method=scenicList");
} catch (SQLException e) {
e.printStackTrace();
JSONObject food = dao.findJSONObject("select * from food where foo_id=?", foo.getFooId());
request.setAttribute("food", food);
request.getRequestDispatcher("food-detail.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
登陆管理控制层:
@WebServlet("/Login")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
BaseDao dao = new BaseDaoImpl();
String img_url = null;
Part part1 = request.getPart("Savatar");
if (part1.getSize() > 0) {
String savepath = service.imagepath(part1);
img_url = savepath;
} else {
img_url = foo.getImgUrl();
Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription(),
foo.getFooId() };
try {
int i = dao.update(
"update food set foo_name = ?,img_url=?,address=?,sce_id=?,description=? where foo_id=?",
ObjectService service = new ObjectService();
ScenicEntity sce = service.setObject(request, ScenicEntity.class);
out = response.getWriter();
// 全局变量类----------------------------------------------------------------------------------------------------------
String method = request.getParameter("method");
System.out.println(method);
int currentPage=1;
if ("scenicList".equals(method)) {// 列表
try {
JSONArray scenic = dao.findJSONArray("select * from scenic");
Object[] params = { sce.getSceId() };
try {
JSONObject scenic = dao.findJSONObject("select * from scenic where sce_id = ?", params);
request.setAttribute("scenic", scenic);
request.getRequestDispatcher("admin-scenicUpdate.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
} else if ("updateScenic1".equals(method)) {// 完成修改
String img_url = null;
Part part1 = request.getPart("Savatar");
if (part1.getSize() > 0) {
String savepath = service.imagepath(part1);
String method = request.getParameter("method");
System.out.println(method);
int currentPage=1;
if ("scenicList".equals(method)) {// 列表
try {
JSONArray scenic = dao.findJSONArray("select * from scenic");
request.setAttribute("scenic", scenic);
request.getRequestDispatcher("admin-scenic.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
} else if ("scenic".equals(method)) {// 列表
try {
JSONArray scenic = dao.findJSONArray("select * from scenic");
} else if ("scenicCllentList".equals(method)) {// 用户查看列表
String ctel = (String) request.getSession().getAttribute("ctel");
// int pageSize=6;
// String currentPage1 = request.getParameter("currentPage");
// System.out.println(currentPage1);
// if(currentPage1!=null) {
// currentPage=Integer.parseInt(currentPage1);
// }
// int pagestart = (currentPage-1)*pageSize;
// System.out.println(pagestart);
try {
// int total=(int) dao.getCount("select count(*) from scenic");
response.sendRedirect("FoodServlet?method=foodList");
} catch (SQLException e) {
e.printStackTrace();
} else if ("deleteFood".equals(method)) {// 删除
try {
int i = dao.update("delete from food where foo_id=?", foo.getFooId());
if (i > 0) {
response.sendRedirect("FoodServlet?method=foodList");
} catch (SQLException e) {
e.printStackTrace();
} else if ("updateFood".equals(method)) {// 修改
Object[] params = { foo.getFooId() };
try {
out.flush();
out.close();
} catch (SQLException e) {
e.printStackTrace();
} else if ("users".equals(method)) {// 管理员信息
JSONArray records;
try {
records = dao.findJSONArray("select * from users where uname=?", use.getUname());
request.setAttribute("records", records);
request.getRequestDispatcher("admin-info.jsp").forward(request, response);
} else if ("detailFood".equals(method)) {// 美食详情
try {
JSONObject food = dao.findJSONObject("select * from food where foo_id=?", foo.getFooId());
request.setAttribute("food", food);
request.getRequestDispatcher("food-detail.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
登陆管理控制层:
@WebServlet("/Login")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
BaseDao dao = new BaseDaoImpl();
PrintWriter out = null;
request.getSession().removeAttribute("utype");
request.getSession().removeAttribute("rootpath");
response.sendRedirect("login.jsp");
} else if ("index".equals(method)) {// 进入首页
String uname = (String) session.getAttribute("uname");
System.out.println(uname);
String utype = "" + session.getAttribute("utype");
request.getSession().setAttribute("rootpath", rootpath);
System.out.println(utype);
if (utype.equals("1")) {
request.getRequestDispatcher("index.jsp").forward(request, response);
} else if ("updateUsers".equals(method)) {// 修改密码
if (user.size() > 0) {
out.write("1");
out.flush();
out.close();
} else if ("exit".equals(method)) {// 退出登录
request.getSession().removeAttribute("uname");
request.getSession().removeAttribute("utype");
request.getSession().removeAttribute("rootpath");
response.sendRedirect("login.jsp");
} else if ("index".equals(method)) {// 进入首页
String uname = (String) session.getAttribute("uname");
} else if ("deleteScenic".equals(method)) {// 删除
try {
int i = dao.update("delete from scenic where sce_id=?", sce.getSceId());
if (i > 0) {
response.sendRedirect("ScenicServlet?method=scenicList");
} catch (SQLException e) {
e.printStackTrace();
} else if ("updateScenic".equals(method)) {// 修改
Object[] params = { sce.getSceId() };
try {
JSONObject scenic = dao.findJSONObject("select * from scenic where sce_id = ?", params);
} catch (SQLException e) {
e.printStackTrace();
} else if ("updateFood".equals(method)) {// 修改
Object[] params = { foo.getFooId() };
try {
JSONObject food = dao.findJSONObject(
"select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_id = ?",
params);
request.setAttribute("food", food);
request.getRequestDispatcher("admin-foodUpdate.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();