基于javaweb+mysql的jsp+servlet电影院售票管理系统(java+servlet+jsp+jdbc+mysql)

基于javaweb+mysql的jsp+servlet电影院售票管理系统(java+servlet+jsp+jdbc+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的JSP+Servlet电影院售票管理系统(java+servlet+jsp+jdbc+mysql)

项目介绍

这个项目是一个基于Servlet+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版本; 6.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术栈

Servlet、JSP、JDBC、MySQL5.7、Tomcat8

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,然后运行; 3. 将项目中src/com/dao/DB.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入localhost:8080/goupiao 管理员账号/密码:admin/admin 会员账号/密码:zhangsan/123456
			}
			finally
			{
				mydb.closed();
			}
			
		}
		
		
		if(userType==1)
		{
			String sql="select * from t_user where loginname=? and loginpw=? and del='no'";
			Object[] params={userName,userPw};
			DB mydb=new DB();
			try
			{
				mydb.doPstm(sql, params);
				ResultSet rs=mydb.getRs();
				boolean mark=(rs==null||!rs.next()?false:true);
				if(mark==false)
				{
					result="no";
				}
				if(mark==true)
				{
					 result="yes";
					 
				     Tuser user=new Tuser();
					
				     user.setId(rs.getString("id"));
					 user.setLoginname(rs.getString("loginname"));
					 user.setLoginpw(rs.getString("loginpw"));
					 user.setName(rs.getString("name"));
					 
					 user.setDel(rs.getString("del"));
					
					 WebContext ctx = WebContextFactory.get(); 
					 HttpSession session=ctx.getSession(); 
					 
					 session.setAttribute("userType", 1);
		
		if(type.endsWith("catelogAdd"))
		{
			catelogAdd(req, res);
		}
		if(type.endsWith("catelogMana"))
		{
			catelogMana(req, res);
		}
		if(type.endsWith("catelogDel"))
		{
			catelogDel(req, res);
		}
	}
	
	public void catelogAdd(HttpServletRequest req,HttpServletResponse res)
	{
		String id=String.valueOf(new Date().getTime());
		String name=req.getParameter("name").trim();
		String del="no";
		
		String sql="insert into t_catelog(id,name,del) values(?,?,?)";
		Object[] params={id,name,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 catelogMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
	{
		List catelogList=new ArrayList();
		String sql="select * from t_catelog where del='no'";
		Object[] params={};
		DB mydb=new DB();
		try
		{
			mydb.doPstm(sql, params);
			ResultSet rs=mydb.getRs();
			while(rs.next())
		catch (ServletException e) 
		{
                    e.printStackTrace();
		} 
		catch (IOException e) 
		{
			
		    e.printStackTrace();
		}
	}
	public void init(ServletConfig config) throws ServletException 
	{
		super.init(config);
	}
	
	public void destroy() 
	{
		
	}
}
package com.service;

public class cartService
{
	public String modiNum(String goodsId,int quantity)
	{
		String result="";
		
		/*if(liuService.getGoods(goodsId).getKucun()<quantity)
		{
			result="no";
		}
	}
	
	
	public void userEditMe(HttpServletRequest req,HttpServletResponse res)
	{
		String id=req.getParameter("id");
		String loginname=req.getParameter("loginname");
		String loginpw=req.getParameter("loginpw");
		String name=req.getParameter("name");
		
		String sql="update t_user set loginname=?,loginpw=?,name=? where id=?";
		Object[] params={loginname,loginpw,name,id};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		mydb.closed();
		
		req.setAttribute("message", "修改成功,重新等后生效");
		req.setAttribute("path", "site/default.jsp");
		
        String targetURL = "/common/success.jsp";
		dispatch(targetURL, req, res);
		
	}
	
	
	public void userMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
	{
		List userList=new ArrayList();
		String sql="select * from t_user where del='no'";
		Object[] params={};
		DB mydb=new DB();
		try
		{
			mydb.doPstm(sql, params);
			ResultSet rs=mydb.getRs();
			while(rs.next())
			{
				Tuser user=new Tuser();
				
				user.setId(rs.getString("id"));
				user.setLoginname(rs.getString("loginname"));
				user.setLoginpw(rs.getString("loginpw"));
				user.setLoginpw(rs.getString("loginpw"));
			Object[] params={userName,userPw};
			DB mydb=new DB();
			mydb.doPstm(sql, params);
			try 
			{
				ResultSet rs=mydb.getRs();
				boolean mark=(rs==null||!rs.next()?false:true);
				if(mark==false)
				{
					 result="no";
				}
				else
				{
					 result="yes";
					 TAdmin admin=new TAdmin();
					 admin.setUserId(rs.getInt("userId"));
					 admin.setUserName(rs.getString("userName"));
					 admin.setUserPw(rs.getString("userPw"));
					 WebContext ctx = WebContextFactory.get(); 
					 HttpSession session=ctx.getSession(); 
					 session.setAttribute("userType", 0);
		             session.setAttribute("admin", admin);
				}
				rs.close();
			} 
			catch (SQLException e)
			{
				System.out.println("登录失败!");
				e.printStackTrace();
			}
			finally
			{
				mydb.closed();
			}
			
		}
		
		
		if(userType==1)
		{
			String sql="select * from t_user where loginname=? and loginpw=? and del='no'";
			Object[] params={userName,userPw};
			DB mydb=new DB();
			try
			{
				mydb.doPstm(sql, params);
				ResultSet rs=mydb.getRs();
				boolean mark=(rs==null||!rs.next()?false:true);
				if(mark==false)
				{
					result="no";
				}
				if(mark==true)
		 Cart cart=(Cart)session.getAttribute("cart");
		 cart.delGoods(goodsId);
		 session.setAttribute("cart", cart);
		 return "yes";
	}
	
	
	public String clearCart()
	{
		 WebContext ctx = WebContextFactory.get(); 
		 HttpSession session=ctx.getSession();
		 Cart cart=(Cart)session.getAttribute("cart");
		 cart.getItems().clear();
		 session.setAttribute("cart", cart);
		 return "yes";
	}
	
}
package com.action;

public class index_servlet extends HttpServlet
{
	public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException 
	{
        req.getSession().setAttribute("catelogList", liuService.catelogList());
        req.getRequestDispatcher("site/index.jsp").forward(req, res);
	}
	
	public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response) 
	{
		RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);

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);
		}
		if(type.endsWith("orderDetail"))
		{
			orderDetail(req, res);
		}
	}
	
	
	public void addToCart(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
	{
		String goods_id=req.getParameter("goods_id");
		int quantity=Integer.parseInt(req.getParameter("quantity"));
		Tgoods goods=liuService.getGoods(goods_id);
		
		TorderItem orderItem=new TorderItem();
		orderItem.setGoods(goods);
		orderItem.setGoods_quantity(quantity);
		
		HttpSession session=req.getSession();
		Cart cart =(Cart)session.getAttribute("cart");
		cart.addGoods(goods_id, orderItem);
		
		session.setAttribute("cart", cart);
		
		req.setAttribute("message", "操作成功");
		req.setAttribute("path", "site/cart/mycart.jsp");
		
		String targetURL = "/common/success.jsp";
		dispatch(targetURL, req, res);
		
		{
			
		}
		return result;
	}
	
	
    public String adminPwEdit(String userPwNew)
    {
		System.out.println("DDDD");
    	try 
		{
			Thread.sleep(700);
		} 
		catch (InterruptedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		WebContext ctx = WebContextFactory.get(); 
		HttpSession session=ctx.getSession(); 
		TAdmin admin=(TAdmin)session.getAttribute("admin");
		
		String sql="update t_admin set userPw=? where userId=?";
		Object[] params={userPwNew,admin.getUserId()};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		
		return "yes";
    }
    
    
    public List catelogAll()
    {
    	try
		{
			Thread.sleep(700);
		} catch (InterruptedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
    	List catelogList=new ArrayList();
		String sql="select * from t_catelog where del='no'";
		Object[] params={};
		DB mydb=new DB();
				ResultSet rs=mydb.getRs();
				boolean mark=(rs==null||!rs.next()?false:true);
				if(mark==false)
				{
					 result="no";
				}
				else
				{
					 result="yes";
					 TAdmin admin=new TAdmin();
					 admin.setUserId(rs.getInt("userId"));
					 admin.setUserName(rs.getString("userName"));
					 admin.setUserPw(rs.getString("userPw"));
					 WebContext ctx = WebContextFactory.get(); 
					 HttpSession session=ctx.getSession(); 
					 session.setAttribute("userType", 0);
		             session.setAttribute("admin", admin);
				}
				rs.close();
			} 
			catch (SQLException e)
			{
				System.out.println("登录失败!");
				e.printStackTrace();
			}
			finally
			{
				mydb.closed();
			}
			
		}
		
		
		if(userType==1)
		{
			String sql="select * from t_user where loginname=? and loginpw=? and del='no'";
			Object[] params={userName,userPw};
			DB mydb=new DB();
			try
			{
				mydb.doPstm(sql, params);
				ResultSet rs=mydb.getRs();
				boolean mark=(rs==null||!rs.next()?false:true);
				if(mark==false)
				{
					result="no";

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);
		}
		if(type.endsWith("orderDetail"))
		{
			orderDetail(req, res);
		}
	}

public class user_servlet extends HttpServlet
{
	
	public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException 
	{
        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"))
		{
			userDel(req, res);
		}
	}
	
	
	public void userReg(HttpServletRequest req,HttpServletResponse res)
	{
		String id=String.valueOf(new Date().getTime());
		String loginname=req.getParameter("loginname");
		}
	}
	public void init(ServletConfig config) throws ServletException 
	{
		super.init(config);
	}
	
	public void destroy() 
	{
		
	}
}
package com.action;

public class catelog_servlet extends HttpServlet
{
	public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException 
	{
        String type=req.getParameter("type");
		
		if(type.endsWith("catelogAdd"))
		{
			catelogAdd(req, res);
		}
		}
		else
		{*/
			 WebContext ctx = WebContextFactory.get(); 
			 HttpSession session=ctx.getSession();
			 Cart cart=(Cart)session.getAttribute("cart");
			 cart.updateCart(goodsId, quantity);
			 session.setAttribute("cart", cart);
			 
			 result="yes";
		/*}*/
		return result;
	}
	
	public String delGoodsFromCart(String goodsId)
	{
		 WebContext ctx = WebContextFactory.get(); 
		 HttpSession session=ctx.getSession();
		 Cart cart=(Cart)session.getAttribute("cart");
		 cart.delGoods(goodsId);
		 session.setAttribute("cart", cart);
		 return "yes";
	}
	
	
	public String clearCart()
	{
		 WebContext ctx = WebContextFactory.get(); 
		 HttpSession session=ctx.getSession();
		 Cart cart=(Cart)session.getAttribute("cart");
		 cart.getItems().clear();
		 session.setAttribute("cart", cart);
		 return "yes";
	}
	
}
package com.action;

		{
			
		}
		return result;
	}
	
	
    public String adminPwEdit(String userPwNew)
    {
		System.out.println("DDDD");
    	try 
		{
			Thread.sleep(700);
		} 
		catch (InterruptedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		WebContext ctx = WebContextFactory.get(); 
		HttpSession session=ctx.getSession(); 
		TAdmin admin=(TAdmin)session.getAttribute("admin");
		
		String sql="update t_admin set userPw=? where userId=?";
		Object[] params={userPwNew,admin.getUserId()};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		
		return "yes";
    }
    
    
    public List catelogAll()
    {
    	try
		{
			Thread.sleep(700);
		} catch (InterruptedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
    	List catelogList=new ArrayList();
		String sql="select * from t_catelog where del='no'";
		Object[] params={};
		DB mydb=new DB();
		try
		{
			mydb.doPstm(sql, params);
		super.init(config);
	}
	
	public void destroy() 
	{
		
	}
}
package com.service;

public class cartService
{
	public String modiNum(String goodsId,int quantity)
	{
		String result="";
		
		/*if(liuService.getGoods(goodsId).getKucun()<quantity)
		{
			result="no";
		}
		else
		{*/
			 WebContext ctx = WebContextFactory.get(); 
			 HttpSession session=ctx.getSession();
			 Cart cart=(Cart)session.getAttribute("cart");
			 cart.updateCart(goodsId, quantity);
			 session.setAttribute("cart", cart);
			 
			 result="yes";
		/*}*/
		return result;
				liuyan.setLiuyanshi(rs.getString("liuyanshi"));
				liuyan.setUser_id(rs.getString("user_id"));
				
				liuyan.setHuifu(rs.getString("huifu"));
				liuyan.setHuifushi(rs.getString("huifushi"));
			
		    }
			rs.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		mydb.closed();
		
		return liuyan;
	}
	
	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);
	}
	
	public void destroy() 
	{
		
	}
}
package com.action;

				   "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();
		String sql="select * from t_goods where del='no' order by fangyingshi desc";
		Object[] params={};
		DB mydb=new DB();
		try
		{
			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"));
				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);
	}
	
	
	
			{
				TLiuyan liuyan=new TLiuyan();
				
				liuyan.setId(rs.getInt("id"));
				liuyan.setNeirong(rs.getString("neirong"));
				liuyan.setLiuyanshi(rs.getString("liuyanshi"));
				liuyan.setUser_id(rs.getString("user_id"));
				
				liuyan.setHuifu(rs.getString("huifu"));
				liuyan.setHuifushi(rs.getString("huifushi"));
			
				liuyanList.add(liuyan);
		    }
			rs.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		mydb.closed();
		
		req.setAttribute("liuyanList", liuyanList);
		req.getRequestDispatcher("admin/liuyan/liuyanMana.jsp").forward(req, res);
	}
	
	public void liuyanDel(HttpServletRequest req,HttpServletResponse res)
	{
		String sql="delete from t_liuyan where id="+Integer.parseInt(req.getParameter("id"));
		Object[] params={};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		mydb.closed();
		
		req.setAttribute("msg", "留言信息删除完毕");
        String targetURL = "/common/msg.jsp";
		dispatch(targetURL, req, res);
	}
	
	
	public void liuyanHuifu(HttpServletRequest req,HttpServletResponse res)
	{
		String huifu=req.getParameter("huifu");
		String huifushi=new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
				user.setId(rs.getString("id"));
				user.setLoginname(rs.getString("loginname"));
				user.setLoginpw(rs.getString("loginpw"));
				user.setLoginpw(rs.getString("loginpw"));
				user.setName(rs.getString("name"));
				
				userList.add(user);
		    }
			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};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		mydb.closed();
		
		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;
			rs.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		mydb.closed();
		
		return liuyan;
	}
	
	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);
	}
	
	public void destroy() 
	{
		
	}
}
package com.action;

public class catelog_servlet extends HttpServlet
{
	public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException 
	{
        String type=req.getParameter("type");
		
		if(type.endsWith("catelogAdd"))
		{
			catelogAdd(req, res);
		}
		if(type.endsWith("catelogMana"))
		{
			catelogMana(req, res);
		}
		if(type.endsWith("catelogDel"))
		{
			catelogDel(req, res);
		}
	}
	
	public void catelogAdd(HttpServletRequest req,HttpServletResponse res)
	{
		String id=String.valueOf(new Date().getTime());
		String name=req.getParameter("name").trim();
		String del="no";
		
		String sql="insert into t_catelog(id,name,del) values(?,?,?)";
		Object[] params={id,name,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 catelogMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
	{
		List catelogList=new ArrayList();
		String sql="select * from t_catelog where del='no'";
		Object[] params={};
		DB mydb=new DB();
		    }
			rs.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		mydb.closed();
		
		req.setAttribute("liuyanList", liuyanList);
		req.getRequestDispatcher("admin/liuyan/liuyanMana.jsp").forward(req, res);
	}
	
	public void liuyanDel(HttpServletRequest req,HttpServletResponse res)
	{
		String sql="delete from t_liuyan where id="+Integer.parseInt(req.getParameter("id"));
		Object[] params={};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		mydb.closed();
		
		req.setAttribute("msg", "留言信息删除完毕");
        String targetURL = "/common/msg.jsp";
		dispatch(targetURL, req, res);
	}
	
	
	public void liuyanHuifu(HttpServletRequest req,HttpServletResponse res)
	{
		String huifu=req.getParameter("huifu");
		String huifushi=new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
		int id=Integer.parseInt(req.getParameter("id"));
		
		String sql="update t_liuyan set huifu=?,huifushi=? where id=?";
		Object[] params={huifu,huifushi,id};
		DB mydb=new DB();
		mydb.doPstm(sql, params);
		mydb.closed();
		
		req.setAttribute("msg", "回复完毕完毕");
        String targetURL = "/common/msg.jsp";
		dispatch(targetURL, req, res);
	}

	public void liuyanAll(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
	}
	
	public void catelogAdd(HttpServletRequest req,HttpServletResponse res)
	{
		String id=String.valueOf(new Date().getTime());
		String name=req.getParameter("name").trim();
		String del="no";
		
		String sql="insert into t_catelog(id,name,del) values(?,?,?)";
		Object[] params={id,name,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 catelogMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
	{
		List catelogList=new ArrayList();
		String sql="select * from t_catelog where del='no'";
		Object[] params={};
		DB mydb=new DB();
		try
		{
			mydb.doPstm(sql, params);
			ResultSet rs=mydb.getRs();
			while(rs.next())
			{
				Tcatelog catelog=new Tcatelog();
				catelog.setId(rs.getString("id"));
				catelog.setName(rs.getString("name"));
				catelogList.add(catelog);
		    }
			rs.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		mydb.closed();
		
		req.setAttribute("catelogList", catelogList);
		req.getRequestDispatcher("admin/catelog/catelogMana.jsp").forward(req, res);
	}

public class loginService
{
	public String login(String userName,String userPw,int userType)
	{
		String result="no";
		
		if(userType==0)//系统管理员登陆
		{
			String sql="select * from t_admin where userName=? and userPw=?";
			Object[] params={userName,userPw};
			DB mydb=new DB();
			mydb.doPstm(sql, params);
			try 
			{
				ResultSet rs=mydb.getRs();
				boolean mark=(rs==null||!rs.next()?false:true);
				if(mark==false)
				{
					 result="no";
				}
				else
				{
					 result="yes";
					 TAdmin admin=new TAdmin();
					 admin.setUserId(rs.getInt("userId"));
			result="no";
		}
		else
		{*/
			 WebContext ctx = WebContextFactory.get(); 
			 HttpSession session=ctx.getSession();
			 Cart cart=(Cart)session.getAttribute("cart");
			 cart.updateCart(goodsId, quantity);
			 session.setAttribute("cart", cart);
			 
			 result="yes";
		/*}*/
		return result;
	}
	
	public String delGoodsFromCart(String goodsId)
	{
		 WebContext ctx = WebContextFactory.get(); 
		 HttpSession session=ctx.getSession();
		 Cart cart=(Cart)session.getAttribute("cart");
		 cart.delGoods(goodsId);
		 session.setAttribute("cart", cart);
		 return "yes";
	}
	
	
	public String clearCart()
	{
		 WebContext ctx = WebContextFactory.get(); 
		 HttpSession session=ctx.getSession();
		 Cart cart=(Cart)session.getAttribute("cart");
		 cart.getItems().clear();
		 session.setAttribute("cart", cart);
		 return "yes";
	}
	
}
package com.action;

	}
	
	
	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);
	}
	
	public void destroy() 
	{
		
	}
}
package com.service;

public class cartService
{
	}
	
	public void destroy() 
	{
		
	}
}
package com.action;

public class liuyan_servlet extends HttpServlet
{
	public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException 
	{
        String type=req.getParameter("type");
		
        if(type.endsWith("liuyanAdd"))
		{
			liuyanAdd(req, res);
		}
        if(type.endsWith("liuyanMana"))
		{
			liuyanMana(req, res);
		}
		if(type.endsWith("liuyanDel"))
		{
			liuyanDel(req, res);
		}
		if(type.endsWith("liuyanHuifu"))
		{
			liuyanHuifu(req, res);
		}
		if(type.endsWith("liuyanAll"))
		{
			liuyanAll(req, res);

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 基于servlet+jsp+mysql开发的JavaWeb学生成绩管理系统,可以实现对学生信息、课程信息和成绩信息的管理。系统的主要功能包括学生信息的添加、修改、删除和查询,课程信息的添加、修改、删除和查询,成绩信息的录入、修改、删除和查询等。同时,系统还可以生成各种报表,如学生信息报表、课程信息报表、成绩信息报表等,方便管理员进行数据分析和决策。系统的开发需要掌握JavaWeb开发技术、ServletJSP的使用、MySQL数据库的操作等知识。 ### 回答2: JavaWeb学生成绩管理系统是一项基于servletjspmysql开发的管理信息系统,旨在为教育管理部门和教师提供一个便利的平台,帮助他们轻松地管理和分析学生成绩和课程信息。 该系统涵盖了学生信息管理、课程信息管理、成绩管理、教师信息管理、管理员信息管理五个模块。在学生信息管理模块,管理员可以添加、修改及删除学生信息,同时可对学生信息进行查询和导出等操作;在课程信息管理模块,管理员可以添加、修改及删除课程信息,同时可对课程信息进行查询和导出等操作。 在成绩管理模块,管理员可以将学生从课程中添加进去,对学生的成绩进行管理、修改及删除等操作。同时,该模块内置了成绩分析和统计功能,使得教师可以使用统计图表看到平均分、最高分、最低成绩等信息,以更好地了解学生的学习情况。 在教师信息管理模块,管理员可以添加、修改及删除教师信息,同时可对教师信息进行查询和导出等操作。教师可以使用该模块对自己授课的课程进行成绩管理并进行统计分析。 在管理员信息管理模块,管理员可以对自己的账号信息进行管理,包括修改密码、添加、删除及修改管理员信息等操作。 总体来说,JavaWeb学生成绩管理系统通过servletjspmysql等技术的应用,实现了对学生成绩、课程等信息进行全方位管理,并且使得数据的统计、排序、查询等功能更加的便捷和高效,为教育管理和学习提供了极大的便利。 ### 回答3: 基于servlet jsp mysql开发javaweb学生成绩管理系统是一种非常实用的系统,可以帮助管理者和学生更好地进行成绩管理。通过该系统,管理者可以随时查看学生的成绩情况,对学生进行动态管理,帮助学生更好地提高成绩。同时,学生也可以随时了解自己在课程中的成绩和提升方向,方便自我调整和完善。 该系统采用了servlet jsp mysql技术进行开发,具有以下优点: 1. 通过servlet技术,可以实现后台数据传输和处理,确保系统的稳定性和安全性; 2. 通过jsp技术,可以实现动态网页的生成和展示,提供更好的用户体验;同时,jsp还可以方便地进行数据查询和修改操作; 3. 通过mysql作为数据库,可以实现数据的存储和管理,确保数据的完整性和可靠性;同时,mysql还具有较高的性能和扩展性,可以满足系统的快速增长。 在实现该系统时,需要进行以下步骤: 1. 分析需求,确定系统的功能和界面设计; 2. 设计数据库结构,确定数据表和字段; 3. 编写servletjsp代码,实现数据的查询、修改和展示功能; 4. 联调测试,确保系统的稳定性和可用性; 5. 部署上线,让用户可以随时使用系统。 总之,基于servlet jsp mysql技术开发javaweb学生成绩管理系统,可以有效提高学生的成绩和帮助管理者更好地管理学生成绩,是一种非常实用和有用的系统。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值