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






基于javaweb的JSP+Servlet旅游推荐系统(java+servlet+html+jdbc+mysql)
项目介绍
旅游推荐网分为前后台,普通用户在前台登录,功能如下:登录、查看热门景点推荐、景点详情、动态查看、联系我们、留言等 管理员通过后台登录,功能如下:登录、留言评审管理、景区管理、用户管理、系统统计等
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目: 否;
技术栈
Servlet、JSP、JDBC、MySQL5.7、Tomcat8
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,然后运行; 3. 将项目中src/com/dao/DB.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入地址; 前台地址:http://localhost:8080/lvyou/qianduan/index.html 普通社员账号:zhangsan 密码:123456
后台地址:http://localhost:8080/lvyou/admin/index.html 管理员账号:admin 密码:admin
——————————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
| String id = request.getParameter("id"); List<PinglunBo> list = new ArrayList<PinglunBo>(); JdbcUtils jdbcUtils = new JdbcUtils(); try { Connection conn = jdbcUtils.getConnection(); Statement stmt = conn.createStatement(); Connection conn1 = jdbcUtils.getConnection(); Statement stmt1 = conn1.createStatement(); String sql = "select * from pinglun where jindian_id = '"+id+"'"; ResultSet result = stmt.executeQuery(sql); PinglunBo pinglun = null; while(result.next()) { pinglun = new PinglunBo(); int id1 = result.getInt("id"); int userId = result.getInt("user_id"); String sql1 = "select * from user where id= '"+userId+"'"; ResultSet result1 = stmt1.executeQuery(sql1); String username = null; while(result1.next()) { username = result1.getString("username"); } pinglun.setId(id1); pinglun.setDetails(result.getString("details")); pinglun.setUsername(username); pinglun.setTime(result.getString("creattime")); list.add(pinglun); } } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); } out.println(JSONObject.fromObject(Msg.success().add("list", list))); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); }
} package com.test.servlet;
|
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
|
public class SelRDjindianServlet extends HttpServlet { private static final long serialVersionUID = 1L;
public SelRDjindianServlet() { super(); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("我进来了。。。。"); response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); List<Jingdian> list = new ArrayList<Jingdian>(); JdbcUtils jdbcUtils = new JdbcUtils(); try { Connection conn = jdbcUtils.getConnection(); Statement stmt = conn.createStatement(); String sql = "select * from scenic_spot where isremeng=1"; ResultSet result = stmt.executeQuery(sql); Jingdian jingdian = null; while(result.next()) { jingdian = new Jingdian(); int id = result.getInt("id"); String name = result.getString("name"); String yiji1 = result.getString("yiji"); String erji1 = result.getString("erji"); String sanji1 = result.getString("sanji"); String jianjie = result.getString("jianjie"); String jianjietu = result.getString("jianjietu"); String wenhua = result.getString("wenhua"); String wenhuatu = result.getString("wenhuatu"); String lishi = result.getString("lishi"); String lishitu = result.getString("lishitu"); String techang = result.getString("techang"); String techangtu = result.getString("techangtu");
|
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
| String jianjie = request.getParameter("jianjie"); String lishi = request.getParameter("lishi"); String wenhua = request.getParameter("wenhua"); String techang = request.getParameter("techang");
String sql = "UPDATE scenic_spot SET yiji = '"+yiji+"', erji = '"+erji+"',sanji= '"+sanji+"',name='"+name+"',jianjie='"+jianjie+"',lishi='"+lishi+"',wenhua='"+wenhua+"',techang='"+techang+"'" + "WHERE id ='"+id+"'"; JdbcUtils jdbcUtils = new JdbcUtils(); try { Connection conn = jdbcUtils.getConnection(); Statement stmt = conn.createStatement(); int dept = stmt.executeUpdate(sql); if(dept==1) { out.println("修改成功!!"); return; }else { out.println("修改失败!!"); return; } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); }
} package com.test.servlet;
|
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
| protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); }
} package com.test.servlet;
public class SelAllPinglunServlet extends HttpServlet { private static final long serialVersionUID = 1L;
public SelAllPinglunServlet() { super(); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("我进来了。。。。");
|
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
|
public class SelliuyanServlet extends HttpServlet { private static final long serialVersionUID = 1L;
public SelliuyanServlet() { super(); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("我进来了。。。。"); response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); int pn = Integer.parseInt(request.getParameter("pn")); System.out.println("pn:"+pn); List<LiuyanBo> list = new ArrayList<LiuyanBo>(); JdbcUtils jdbcUtils = new JdbcUtils(); try { Connection conn = jdbcUtils.getConnection(); Statement stmt = conn.createStatement(); Connection conn1 = jdbcUtils.getConnection(); Statement stmt1 = conn1.createStatement(); String sql = "select * from liuyan"; ResultSet result = stmt.executeQuery(sql); LiuyanBo liuyan = null; while(result.next()) {
|
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
| private static final long serialVersionUID = 1L;
public SelliuyanServlet() { super(); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("我进来了。。。。"); response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); int pn = Integer.parseInt(request.getParameter("pn")); System.out.println("pn:"+pn); List<LiuyanBo> list = new ArrayList<LiuyanBo>(); JdbcUtils jdbcUtils = new JdbcUtils(); try { Connection conn = jdbcUtils.getConnection(); Statement stmt = conn.createStatement(); Connection conn1 = jdbcUtils.getConnection(); Statement stmt1 = conn1.createStatement(); String sql = "select * from liuyan"; ResultSet result = stmt.executeQuery(sql); LiuyanBo liuyan = null; while(result.next()) { liuyan = new LiuyanBo(); int id = result.getInt("id"); int userId = result.getInt("user_id"); String sql1 = "select * from user where id= '"+userId+"'"; ResultSet result1 = stmt1.executeQuery(sql1); String username = null; while(result1.next()) { username = result1.getString("username"); } liuyan.setChenghu(result.getString("chenghu")); liuyan.setId(result.getInt("id")); liuyan.setPhone(result.getString("phone")); liuyan.setSex(result.getString("sex")); liuyan.setTime(result.getString("creattime"));
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=431023491103200ys
https://javayms.pages.dev?id=431023491103200ys