基于javaweb+mysql的jsp+servlet电影院管理系统(java+servlet+jsp+jdbc+layui+bootstrap+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet电影院管理系统(java+servlet+jsp+jdbc+layui+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、8.0等版本均可; 6.是否Maven项目: 否;
技术栈
Servlet、JSP、JDBC、MySQL5.7/8.0、Tomcat8、jquery、layui、bootstrap等
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目; 3. 将项目中util/JdbcUtil.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录 管理员账号/密码:admin/123456 用户账号/密码:test/123456
orderShouli(req, res);
public void orderMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
List orderList=new ArrayList();
String sql="select * from t_order order by zhuangtai desc";
Object[] params={};
DB mydb=new DB();
try
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
Torder order=new Torder();
order.setId(rs.getString("id"));
public void orderSubmit(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
String songhuodizhi=req.getParameter("songhuodizhi");
String fukuanfangshi=req.getParameter("fukuanfangshi");
HttpSession session=req.getSession();
Cart cart =(Cart)session.getAttribute("cart");
Tuser user=(Tuser)session.getAttribute("user");
Torder order=new Torder();
order.setId(String.valueOf(new Date().getTime()));
order.setBianhao(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
order.setShijian(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
"values(?,?,?,?,?,?,?,?,?)";
Object[] params={id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "操作成功");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
public void goodsMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
List goodsList=new ArrayList();
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
dispatch.forward(request, response);
return;
catch (ServletException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
public void init(ServletConfig config) throws ServletException
String id=req.getParameter("id");
req.setAttribute("goods", liuService.getGoods(id));
req.getRequestDispatcher("admin/goods/goodsDetailHou.jsp").forward(req, res);
public void goodsAll(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
List goodsList=new ArrayList();
//String sql="select * from t_goods where del='no' and fangyingshi >? order by fangyingshi desc";
String sql="select * from t_goods where del='no' order by fangyingshi desc";
Object[] params={new SimpleDateFormat("yyyy-MM-dd").format(new Date())};
DB mydb=new DB();
try
mydb.doPstm(sql, null);
ResultSet rs=mydb.getRs();
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
Tgoods goods=new Tgoods();
goods.setId(rs.getString("id"));
goods.setFangyingshi(rs.getString("fangyingshi"));
goods.setCatelog_id(rs.getString("catelog_id"));
goods.setMingcheng(rs.getString("mingcheng"));
goods.setJieshao(rs.getString("jieshao"));
goods.setFujian(rs.getString("fujian"));
goods.setShichangjia(rs.getInt("shichangjia"));
goods.setTejia(rs.getInt("tejia"));
catch (IOException e)
e.printStackTrace();
public void init(ServletConfig config) throws ServletException
super.init(config);
public void destroy()
订单管理控制层:
public class order_servlet extends HttpServlet
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
String type=req.getParameter("type");
if(type.endsWith("orderMana"))
orderMana(req, res);
if(type.endsWith("orderDel"))
orderDel(req, res);
goods.setShichangjia(rs.getInt("shichangjia"));
goods.setTejia(rs.getInt("tejia"));
goods.setDel(rs.getString("del"));
goodsList.add(goods);
rs.close();
catch(Exception e)
e.printStackTrace();
mydb.closed();
if(goodsList.size()>8)
goodsList=goodsList.subList(0, 8);
req.setAttribute("goodsList", goodsList);
rs.close();
catch(Exception e)
e.printStackTrace();
mydb.closed();
req.setAttribute("userList", userList);
req.getRequestDispatcher("admin/user/userMana.jsp").forward(req, res);
public void userDel(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
String id=req.getParameter("id");
String sql="update t_user set del='yes' where id=?";
Object[] params={id};
order.setShijian(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
order.setZhuangtai("no");
order.setSonghuodizhi(songhuodizhi);
order.setFukuanfangshi(fukuanfangshi);
order.setJine(cart.getTotalPrice());
order.setUser_id(user.getId());
liuService.saveOrder(order);
for (Iterator it = cart.getItems().values().iterator(); it.hasNext();)
TorderItem orderItem = (TorderItem) it.next();
String id=String.valueOf(new Date().getTime());
String order_id=order.getId();
req.setAttribute("orderItemList", liuService.orderItemList(order_id));
req.getRequestDispatcher("site/order/orderDetail.jsp").forward(req, res);
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
dispatch.forward(request, response);
return;
catch (ServletException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
public void init(ServletConfig config) throws ServletException
super.init(config);
req.setAttribute("msg", "用户信息删除完毕");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
dispatch.forward(request, response);
return;
catch (ServletException e)
e.printStackTrace();
catch (IOException e)
public void goodsAdd(HttpServletRequest req,HttpServletResponse res)
String id=String.valueOf(new Date().getTime());
String fangyingshi=req.getParameter("fangyingshi");
String catelog_id=req.getParameter("catelog_id");
String mingcheng=req.getParameter("mingcheng");
String jieshao=req.getParameter("jieshao");
String fujian=req.getParameter("fujian");
int shichangjia=Integer.parseInt(req.getParameter("shichangjia"));
int tejia=Integer.parseInt(req.getParameter("shichangjia"));
String del="no";
String sql="insert into t_goods(id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del) " +
"values(?,?,?,?,?,?,?,?,?)";
Object[] params={id,fangyingshi,catelog_id,mingcheng,jieshao,fujian,shichangjia,tejia,del};
catch(Exception e)
e.printStackTrace();
mydb.closed();
if(goodsList.size()>8)
goodsList=goodsList.subList(0, 8);
req.setAttribute("goodsList", goodsList);
req.getRequestDispatcher("site/goods/goodsAll.jsp").forward(req, res);
public void goodsByCatelog(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
String catelog_id=req.getParameter("catelog_id");
req.setAttribute("goodsList", liuService.goodsByCatelog(catelog_id));
mydb.closed();
req.setAttribute("orderList", orderList);
req.getRequestDispatcher("admin/order/orderMana.jsp").forward(req, res);
public void orderDel(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
String id=req.getParameter("id");
String sql="delete from t_order where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "信息删除完毕");
String type=req.getParameter("type");
if(type.endsWith("userReg"))
userReg(req, res);
if(type.endsWith("userLogout"))
userLogout(req, res);
if(type.endsWith("userEditMe"))
userEditMe(req, res);
if(type.endsWith("userMana"))
userMana(req, res);
if(type.endsWith("userDel"))
goods.setFujian(rs.getString("fujian"));
goods.setShichangjia(rs.getInt("shichangjia"));
goods.setTejia(rs.getInt("tejia"));
goods.setDel(rs.getString("del"));
goodsList.add(goods);
rs.close();
catch(Exception e)
e.printStackTrace();
mydb.closed();
req.setAttribute("goodsList", goodsList);
req.getRequestDispatcher("admin/goods/goodsMana.jsp").forward(req, res);
super.init(config);
public void destroy()
购物车管理控制层:
public class buy_servlet extends HttpServlet
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
String type=req.getParameter("type");
if(type.endsWith("addToCart"))
addToCart(req, res);
if(type.endsWith("orderSubmit"))
orderSubmit(req, res);
if(type.endsWith("myorder"))
myorder(req, res);