当前位置:   article > 正文

Java项目:电影院管理系统(java+Servlet+JSP+JDBC+layui+bootstrap+mysql)_jsp程序设计电影网站系统

jsp程序设计电影网站系统

源码获取:俺的博客首页 "资源" 里下载! 

项目介绍

本项目包含前后台,前台为普通用户登录,后台为管理员登录。
管理员角色包含以下功能:
用户管理,电影管理,影院管理、放映厅管理、场次管理、评论管理、订单管理等功能。

用户角色包含以下功能:
首页、电影详情查看、购票、选座、支付、查看订单、搜索电影、发表评论等功能;


环境需要

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、8.0等版本均可;
6.是否Maven项目: 否;


技术栈

Servlet、JSP、JDBC、MySQL5.7/8.0、Tomcat8、jquery、layui、bootstrap等


使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目;
3. 将项目中util/JdbcUtil.java配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
管理员账号/密码:admin/123456
用户账号/密码:test/123456

 

 

 

 

 

 

 

用户管理控制层:

  1. public class user_servlet extends HttpServlet
  2. {
  3. public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  4. {
  5. String type=req.getParameter("type");
  6. if(type.endsWith("userReg"))
  7. {
  8. userReg(req, res);
  9. }
  10. if(type.endsWith("userLogout"))
  11. {
  12. userLogout(req, res);
  13. }
  14. if(type.endsWith("userEditMe"))
  15. {
  16. userEditMe(req, res);
  17. }
  18. if(type.endsWith("userMana"))
  19. {
  20. userMana(req, res);
  21. }
  22. if(type.endsWith("userDel"))
  23. {
  24. userDel(req, res);
  25. }
  26. }
  27. public void userReg(HttpServletRequest req,HttpServletResponse res)
  28. {
  29. String id=String.valueOf(new Date().getTime());
  30. String loginname=req.getParameter("loginname");
  31. String loginpw=req.getParameter("loginpw");
  32. String name=req.getParameter("name");
  33. String del="no";
  34. String s=liuService.panduan_zhanghao(loginname);
  35. if(s.equals("yizhan"))
  36. {
  37. req.setAttribute("message", "账号已被占用,请输入其他账号");
  38. req.setAttribute("path", "site/userreg/userreg.jsp");
  39. String targetURL = "/common/success.jsp";
  40. dispatch(targetURL, req, res);
  41. }
  42. else
  43. {
  44. String sql="insert into t_user values(?,?,?,?,?)";
  45. Object[] params={id,loginname,loginpw,name,del};
  46. DB mydb=new DB();
  47. mydb.doPstm(sql, params);
  48. mydb.closed();
  49. req.setAttribute("message", "注册成功,请登录");
  50. req.setAttribute("path", "site/default.jsp");
  51. String targetURL = "/common/success.jsp";
  52. dispatch(targetURL, req, res);
  53. }
  54. }
  55. public void userLogout(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  56. {
  57. HttpSession session=req.getSession();
  58. session.setAttribute("userType", null);
  59. session.setAttribute("user", null);
  60. req.setAttribute("message", "成功退出系统");
  61. req.setAttribute("path", "site/default.jsp");
  62. String targetURL = "/common/success.jsp";
  63. dispatch(targetURL, req, res);
  64. }
  65. public void userEditMe(HttpServletRequest req,HttpServletResponse res)
  66. {
  67. String id=req.getParameter("id");
  68. String loginname=req.getParameter("loginname");
  69. String loginpw=req.getParameter("loginpw");
  70. String name=req.getParameter("name");
  71. String sql="update t_user set loginname=?,loginpw=?,name=? where id=?";
  72. Object[] params={loginname,loginpw,name,id};
  73. DB mydb=new DB();
  74. mydb.doPstm(sql, params);
  75. mydb.closed();
  76. req.setAttribute("message", "修改成功,重新等后生效");
  77. req.setAttribute("path", "site/default.jsp");
  78. String targetURL = "/common/success.jsp";
  79. dispatch(targetURL, req, res);
  80. }
  81. public void userMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  82. {
  83. List userList=new ArrayList();
  84. String sql="select * from t_user where del='no'";
  85. Object[] params={};
  86. DB mydb=new DB();
  87. try
  88. {
  89. mydb.doPstm(sql, params);
  90. ResultSet rs=mydb.getRs();
  91. while(rs.next())
  92. {
  93. Tuser user=new Tuser();
  94. user.setId(rs.getString("id"));
  95. user.setLoginname(rs.getString("loginname"));
  96. user.setLoginpw(rs.getString("loginpw"));
  97. user.setLoginpw(rs.getString("loginpw"));
  98. user.setName(rs.getString("name"));
  99. userList.add(user);
  100. }
  101. rs.close();
  102. }
  103. catch(Exception e)
  104. {
  105. e.printStackTrace();
  106. }
  107. mydb.closed();
  108. req.setAttribute("userList", userList);
  109. req.getRequestDispatcher("admin/user/userMana.jsp").forward(req, res);
  110. }
  111. public void userDel(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  112. {
  113. String id=req.getParameter("id");
  114. String sql="update t_user set del='yes' where id=?";
  115. Object[] params={id};
  116. DB mydb=new DB();
  117. mydb.doPstm(sql, params);
  118. mydb.closed();
  119. req.setAttribute("msg", "用户信息删除完毕");
  120. String targetURL = "/common/msg.jsp";
  121. dispatch(targetURL, req, res);
  122. }
  123. public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
  124. {
  125. RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
  126. try
  127. {
  128. dispatch.forward(request, response);
  129. return;
  130. }
  131. catch (ServletException e)
  132. {
  133. e.printStackTrace();
  134. }
  135. catch (IOException e)
  136. {
  137. e.printStackTrace();
  138. }
  139. }
  140. public void init(ServletConfig config) throws ServletException
  141. {
  142. super.init(config);
  143. }
  144. public void destroy()
  145. {
  146. }
  147. }

订单管理控制层:

  1. public class order_servlet extends HttpServlet
  2. {
  3. public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  4. {
  5. String type=req.getParameter("type");
  6. if(type.endsWith("orderMana"))
  7. {
  8. orderMana(req, res);
  9. }
  10. if(type.endsWith("orderDel"))
  11. {
  12. orderDel(req, res);
  13. }
  14. if(type.endsWith("orderShouli"))
  15. {
  16. orderShouli(req, res);
  17. }
  18. }
  19. public void orderMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  20. {
  21. List orderList=new ArrayList();
  22. String sql="select * from t_order order by zhuangtai desc";
  23. Object[] params={};
  24. DB mydb=new DB();
  25. try
  26. {
  27. mydb.doPstm(sql, params);
  28. ResultSet rs=mydb.getRs();
  29. while(rs.next())
  30. {
  31. Torder order=new Torder();
  32. order.setId(rs.getString("id"));
  33. order.setBianhao(rs.getString("bianhao"));
  34. order.setShijian(rs.getString("shijian"));
  35. order.setZhuangtai(rs.getString("zhuangtai"));
  36. order.setSonghuodizhi(rs.getString("songhuodizhi"));
  37. order.setFukuanfangshi(rs.getString("fukuanfangshi"));
  38. order.setJine(rs.getInt("jine"));
  39. order.setUser_id(rs.getString("user_id"));
  40. orderList.add(order);
  41. }
  42. rs.close();
  43. }
  44. catch(Exception e)
  45. {
  46. e.printStackTrace();
  47. }
  48. mydb.closed();
  49. req.setAttribute("orderList", orderList);
  50. req.getRequestDispatcher("admin/order/orderMana.jsp").forward(req, res);
  51. }
  52. public void orderDel(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  53. {
  54. String id=req.getParameter("id");
  55. String sql="delete from t_order where id=?";
  56. Object[] params={id};
  57. DB mydb=new DB();
  58. mydb.doPstm(sql, params);
  59. mydb.closed();
  60. req.setAttribute("msg", "信息删除完毕");
  61. String targetURL = "/common/msg.jsp";
  62. dispatch(targetURL, req, res);
  63. }
  64. public void orderShouli(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  65. {
  66. String id=req.getParameter("id");
  67. String sql="update t_order set zhuangtai='yes' where id=?";
  68. Object[] params={id};
  69. DB mydb=new DB();
  70. mydb.doPstm(sql, params);
  71. mydb.closed();
  72. req.setAttribute("msg", "订单受理完毕");
  73. String targetURL = "/common/msg.jsp";
  74. dispatch(targetURL, req, res);
  75. }
  76. public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
  77. {
  78. RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
  79. try
  80. {
  81. dispatch.forward(request, response);
  82. return;
  83. }
  84. catch (ServletException e)
  85. {
  86. e.printStackTrace();
  87. }
  88. catch (IOException e)
  89. {
  90. e.printStackTrace();
  91. }
  92. }
  93. public void init(ServletConfig config) throws ServletException
  94. {
  95. super.init(config);
  96. }
  97. public void destroy()
  98. {
  99. }
  100. }

电影管理控制层:

  1. public class goods_servlet extends HttpServlet
  2. {
  3. public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  4. {
  5. String type=req.getParameter("type");
  6. if(type.endsWith("goodsAdd"))
  7. {
  8. goodsAdd(req, res);
  9. }
  10. if(type.endsWith("goodsMana"))
  11. {
  12. goodsMana(req, res);
  13. }
  14. if(type.endsWith("goodsDel"))
  15. {
  16. goodsDel(req, res);
  17. }
  18. if(type.endsWith("goodsDetailHou"))
  19. {
  20. goodsDetailHou(req, res);
  21. }
  22. if(type.endsWith("goodsAll"))
  23. {
  24. goodsAll(req, res);
  25. }
  26. if(type.endsWith("goodsByCatelog"))
  27. {
  28. goodsByCatelog(req, res);
  29. }
  30. if(type.endsWith("goodsDetailQian"))
  31. {
  32. goodsDetailQian(req, res);
  33. }
  34. }
  35. public void goodsAdd(HttpServletRequest req,HttpServletResponse res)
  36. {
  37. String id=String.valueOf(new Date().getTime());
  38. String fangyingshi=req.getParameter("fangyingshi");
  39. String catelog_id=req.getParameter("catelog_id");
  40. String mingcheng=req.getParameter("mingcheng");
  41. String jieshao=req.getParameter("jieshao");
  42. String fujian=req.getParameter("fujian");
  43. int shichangjia=Integer.parseInt(req.getParameter("shichangjia"));
  44. int tejia=Integer.parseInt(req.getParameter("shichangjia"));
  45. String del="no";
  46. String sql="insert into t_goods(id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del) " +
  47. "values(?,?,?,?,?,?,?,?,?)";
  48. Object[] params={id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del};
  49. DB mydb=new DB();
  50. mydb.doPstm(sql, params);
  51. mydb.closed();
  52. req.setAttribute("msg", "操作成功");
  53. String targetURL = "/common/msg.jsp";
  54. dispatch(targetURL, req, res);
  55. }
  56. public void goodsMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  57. {
  58. List goodsList=new ArrayList();
  59. String sql="select * from t_goods where del='no' order by fangyingshi desc";
  60. Object[] params={};
  61. DB mydb=new DB();
  62. try
  63. {
  64. mydb.doPstm(sql, params);
  65. ResultSet rs=mydb.getRs();
  66. while(rs.next())
  67. {
  68. Tgoods goods=new Tgoods();
  69. goods.setId(rs.getString("id"));
  70. goods.setFangyingshi(rs.getString("fangyingshi"));
  71. goods.setCatelog_id(rs.getString("catelog_id"));
  72. goods.setMingcheng(rs.getString("mingcheng"));
  73. goods.setJieshao(rs.getString("jieshao"));
  74. goods.setFujian(rs.getString("fujian"));
  75. goods.setShichangjia(rs.getInt("shichangjia"));
  76. goods.setTejia(rs.getInt("tejia"));
  77. goods.setDel(rs.getString("del"));
  78. goodsList.add(goods);
  79. }
  80. rs.close();
  81. }
  82. catch(Exception e)
  83. {
  84. e.printStackTrace();
  85. }
  86. mydb.closed();
  87. req.setAttribute("goodsList", goodsList);
  88. req.getRequestDispatcher("admin/goods/goodsMana.jsp").forward(req, res);
  89. }
  90. public void goodsDel(HttpServletRequest req,HttpServletResponse res)
  91. {
  92. String id=req.getParameter("id");
  93. String sql="update t_goods set del='yes' where id="+id;
  94. Object[] params={};
  95. DB mydb=new DB();
  96. mydb.doPstm(sql, params);
  97. mydb.closed();
  98. req.setAttribute("msg", "操作成功");
  99. String targetURL = "/common/msg.jsp";
  100. dispatch(targetURL, req, res);
  101. }
  102. public void goodsDetailHou(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  103. {
  104. String id=req.getParameter("id");
  105. req.setAttribute("goods", liuService.getGoods(id));
  106. req.getRequestDispatcher("admin/goods/goodsDetailHou.jsp").forward(req, res);
  107. }
  108. public void goodsAll(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  109. {
  110. List goodsList=new ArrayList();
  111. //String sql="select * from t_goods where del='no' and fangyingshi >? order by fangyingshi desc";
  112. String sql="select * from t_goods where del='no' order by fangyingshi desc";
  113. Object[] params={new SimpleDateFormat("yyyy-MM-dd").format(new Date())};
  114. DB mydb=new DB();
  115. try
  116. {
  117. mydb.doPstm(sql, null);
  118. ResultSet rs=mydb.getRs();
  119. while(rs.next())
  120. {
  121. Tgoods goods=new Tgoods();
  122. goods.setId(rs.getString("id"));
  123. goods.setFangyingshi(rs.getString("fangyingshi"));
  124. goods.setCatelog_id(rs.getString("catelog_id"));
  125. goods.setMingcheng(rs.getString("mingcheng"));
  126. goods.setJieshao(rs.getString("jieshao"));
  127. goods.setFujian(rs.getString("fujian"));
  128. goods.setShichangjia(rs.getInt("shichangjia"));
  129. goods.setTejia(rs.getInt("tejia"));
  130. goods.setDel(rs.getString("del"));
  131. goodsList.add(goods);
  132. }
  133. rs.close();
  134. }
  135. catch(Exception e)
  136. {
  137. e.printStackTrace();
  138. }
  139. mydb.closed();
  140. if(goodsList.size()>8)
  141. {
  142. goodsList=goodsList.subList(0, 8);
  143. }
  144. req.setAttribute("goodsList", goodsList);
  145. req.getRequestDispatcher("site/goods/goodsAll.jsp").forward(req, res);
  146. }
  147. public void goodsByCatelog(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  148. {
  149. String catelog_id=req.getParameter("catelog_id");
  150. req.setAttribute("goodsList", liuService.goodsByCatelog(catelog_id));
  151. req.getRequestDispatcher("site/goods/goodsByCatelog.jsp").forward(req, res);
  152. }
  153. public void goodsDetailQian(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  154. {
  155. String id=req.getParameter("id");
  156. req.setAttribute("goods", liuService.getGoods(id));
  157. req.getRequestDispatcher("site/goods/goodsDetailQian.jsp").forward(req, res);
  158. }
  159. public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
  160. {
  161. RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
  162. try
  163. {
  164. dispatch.forward(request, response);
  165. return;
  166. }
  167. catch (ServletException e)
  168. {
  169. e.printStackTrace();
  170. }
  171. catch (IOException e)
  172. {
  173. e.printStackTrace();
  174. }
  175. }
  176. public void init(ServletConfig config) throws ServletException
  177. {
  178. super.init(config);
  179. }
  180. public void destroy()
  181. {
  182. }
  183. }

购物车管理控制层: 

  1. public class buy_servlet extends HttpServlet
  2. {
  3. public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  4. {
  5. String type=req.getParameter("type");
  6. if(type.endsWith("addToCart"))
  7. {
  8. addToCart(req, res);
  9. }
  10. if(type.endsWith("orderSubmit"))
  11. {
  12. orderSubmit(req, res);
  13. }
  14. if(type.endsWith("myorder"))
  15. {
  16. myorder(req, res);
  17. }
  18. if(type.endsWith("orderDetail"))
  19. {
  20. orderDetail(req, res);
  21. }
  22. }
  23. public void addToCart(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  24. {
  25. String goods_id=req.getParameter("goods_id");
  26. int quantity=Integer.parseInt(req.getParameter("quantity"));
  27. Tgoods goods=liuService.getGoods(goods_id);
  28. TorderItem orderItem=new TorderItem();
  29. orderItem.setGoods(goods);
  30. orderItem.setGoods_quantity(quantity);
  31. HttpSession session=req.getSession();
  32. Cart cart =(Cart)session.getAttribute("cart");
  33. cart.addGoods(goods_id, orderItem);
  34. session.setAttribute("cart", cart);
  35. req.setAttribute("message", "操作成功");
  36. req.setAttribute("path", "site/cart/mycart.jsp");
  37. String targetURL = "/common/success.jsp";
  38. dispatch(targetURL, req, res);
  39. }
  40. public void orderSubmit(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  41. {
  42. String songhuodizhi=req.getParameter("songhuodizhi");
  43. String fukuanfangshi=req.getParameter("fukuanfangshi");
  44. HttpSession session=req.getSession();
  45. Cart cart =(Cart)session.getAttribute("cart");
  46. Tuser user=(Tuser)session.getAttribute("user");
  47. Torder order=new Torder();
  48. order.setId(String.valueOf(new Date().getTime()));
  49. order.setBianhao(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
  50. order.setShijian(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
  51. order.setZhuangtai("no");
  52. order.setSonghuodizhi(songhuodizhi);
  53. order.setFukuanfangshi(fukuanfangshi);
  54. order.setJine(cart.getTotalPrice());
  55. order.setUser_id(user.getId());
  56. liuService.saveOrder(order);
  57. for (Iterator it = cart.getItems().values().iterator(); it.hasNext();)
  58. {
  59. TorderItem orderItem = (TorderItem) it.next();
  60. String id=String.valueOf(new Date().getTime());
  61. String order_id=order.getId();
  62. String goods_id=orderItem.getGoods().getId();
  63. int goods_quantity=orderItem.getGoods_quantity();
  64. liuService.saveOrderItem(id, order_id, goods_id, goods_quantity);
  65. liuService.updateGoodsKucun(goods_id, goods_quantity);
  66. }
  67. cart.getItems().clear();
  68. session.setAttribute("cart", cart);
  69. req.setAttribute("order", order);
  70. req.getRequestDispatcher("site/order/orderSubmit.jsp").forward(req, res);
  71. }
  72. public void myorder(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  73. {
  74. HttpSession session=req.getSession();
  75. Tuser user=(Tuser)session.getAttribute("user");
  76. req.setAttribute("orderList", liuService.orderList(user.getId()));
  77. req.getRequestDispatcher("site/order/myorder.jsp").forward(req, res);
  78. }
  79. public void orderDetail(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
  80. {
  81. String order_id=req.getParameter("order_id");
  82. System.out.println(order_id+"DD");
  83. req.setAttribute("orderItemList", liuService.orderItemList(order_id));
  84. req.getRequestDispatcher("site/order/orderDetail.jsp").forward(req, res);
  85. }
  86. public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
  87. {
  88. RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
  89. try
  90. {
  91. dispatch.forward(request, response);
  92. return;
  93. }
  94. catch (ServletException e)
  95. {
  96. e.printStackTrace();
  97. }
  98. catch (IOException e)
  99. {
  100. e.printStackTrace();
  101. }
  102. }
  103. public void init(ServletConfig config) throws ServletException
  104. {
  105. super.init(config);
  106. }
  107. public void destroy()
  108. {
  109. }
  110. }

 

源码获取:俺的博客首页 "资源" 里下载!

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号