——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的JSP+Servlet在线旅游美食展现管理系统(java+servlet+jsp+bootstrap+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版本;
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入localhost:8080/
——————————CodeStart——————————
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
| ob.outWrite(out, flag); } else { session.setAttribute("rootpath", rootpath); session.setAttribute("cname", cllent.getCllName()); session.setAttribute("ctel", cllent.getCtel()); flag = "3"; ob.outWrite(out, flag); }
} catch (SQLException e) { e.printStackTrace(); }
} else if ("registe".equals(method)) { try { String flag = "0"; String sql = "select * from cllent where ctel=" + cll.getCtel(); cllent = db.findBean(CllentEntity.class, sql); if (cllent == null) { sql = "insert into cllent(ctel,password,id_code) values(?,?,?)"; Object[] params = {cll.getCtel(), cll.getPassword(),ob.getRandom() }; int i = db.update(sql, params); System.out.println(i); if (i != 0) { flag="2"; ob.outWrite(out, flag); }
}else { flag="1"; ob.outWrite(out, flag); } } catch (SQLException e) { e.printStackTrace(); } } else if ("recover".equals(method)) { try { String flag = "0"; String sql = "select * from cllent where Ctel=" + cll.getCtel(); cllent = db.findBean(CllentEntity.class, sql);
if (cllent != null) { sql = "select * from cllent where Ctel = ? and id_code=? "; cllent = db.findBean(CllentEntity.class, sql,cll.getCtel(),cll.getIdCode());
if (cllent!=null) { flag="2"; sql = "update cllent set password=? where ctel=?"; Object[] params = { cll.getPassword(), cll.getCtel() }; int i = db.update(sql, params); sql = "insert into log(ctel,time,message) values(?,?,?)"; Object[] params1 = { cll.getCtel(), ob.getNowTime(), "用户["+cll.getCtel()+"]重置了密码" };
|
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
| try { System.out.println(foo.getFooName()); JSONArray food = dao.findJSONArray( "select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_name like '%" + foo.getFooName() + "%'"); String sceId = request.getParameter("sceId"); System.out.println(sceId); if (sceId != null && sceId != "") { food = dao.findJSONArray( "select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.sce_id=" + sceId + " and f.foo_name like '%" + foo.getFooName() + "%'"); } request.setAttribute("food", food); request.getRequestDispatcher("admin-food.jsp").forward(request, response); } catch (SQLException e) { e.printStackTrace(); } } else if ("foodAdd".equals(method)) { Part part = request.getPart("Savatar"); String heads_url = service.imagepath(part); String img_url = heads_url; Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription() }; try { int i = dao.update("INSERT INTO food(foo_name,img_url,address,sce_id,description) VALUES(?,?,?,?,?)", params); if (i > 0) { 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 { JSONObject food = dao.findJSONObject(
|
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
| String uname = (String) request.getSession().getAttribute("uname"); Object[] params = { pwd1, uname }; try { int m = (int) dao.getCount("select count(*) from users where password = ?", pwd); if (m > 0) { dao.update("update users set password = ? where uname = ?", params); out.write("1"); out.flush(); out.close(); } else { out.write("2"); 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); } catch (SQLException e) { e.printStackTrace(); } }
} } package com.travel.controller;
|
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
| int i = dao.update("update cllent set cll_name = ?,csex=?,id_code=?,age=? where ctel=?", params1); if(i>0) { response.sendRedirect("Cllent?method=cllentList"); } } catch (SQLException e) { e.printStackTrace(); } } else if ("cllent".equals(method)) { String uname = (String) session.getAttribute("uname"); JSONArray cllent; try { cllent = dao.findJSONArray( "select u.*,c.* from users u join cllent c on c.uname=u.uname where u.uname=?", uname); System.out.println(cllent); request.setAttribute("cllent", cllent); request.getRequestDispatcher("cllent-info.jsp").forward(request, response); } catch (SQLException e) { e.printStackTrace(); } } }
} package com.travel.controller;
|
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
| } else if ("scenicAdd".equals(method)) { Part part = request.getPart("Savatar"); String heads_url = service.imagepath(part); String img_url = heads_url; System.out.println(sce.getRegionId()); Object[] params = { sce.getSceName(), sce.getRegionId(), img_url, sce.getAddress(), sce.getDescription() }; try { int i = dao.update( "INSERT INTO scenic(sce_name,region_id,img_url,address,description) VALUES(?,?,?,?,?)", params); if (i > 0) { response.sendRedirect("ScenicServlet?method=scenicList"); } } catch (SQLException e) { e.printStackTrace(); } } 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); 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); 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) {
|
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
|
@WebServlet("/IndexFrontServlet") public class IndexFrontServlet extends HttpServlet { private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8");
BaseDao db = new BaseDaoImpl(); ObjectService ob = new ObjectService(); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); CllentEntity cll = ob.setObject(request, CllentEntity.class); CllentEntity cllent = new CllentEntity(); String method = request.getParameter("method"); System.out.println(method); File[] files = File.listRoots(); String rootpath = files[files.length - 1].getPath(); if ("login".equals(method)) { try {
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=291122572008200tl
https://javayms.pages.dev?id=291122572008200tl