基于Java网上花店系统设计实现(源码+部署文档)

2023-12-26 18:59:08

博主介绍: ?至今服务客户已经1000+、专注于Java技术领域、项目定制、技术答疑、开发工具、毕业项目实战 ?
🍅 文末获取源码联系 🍅
👇🏻 精彩专栏 推荐订阅 👇🏻 不然下次找不到

Java项目精品实战专区icon-default.png?t=N7T8https://blog.csdn.net/java18343246781/category_12537229.htmlJava各种开发工具资源包网站icon-default.png?t=N7T8http://62.234.13.119:9000/html/visitor/softwareResourceList.html


系列文章目录

前言

一、运行环境

二、代码示例

三、系统展示


前言

? 这个网上花店系统的前端采用了先进的技术,涵盖了多项关键功能,以满足用户在选购鲜花时的各种需求。以下是其中一些主要功能的简要介绍:

商城列表:用户可以通过商城列表轻松浏览各类精选鲜花,系统通过清晰的界面呈现丰富的花卉信息,使用户能够迅速找到心仪的花束。

加入购物车:购物车是用户选购鲜花的中转站,通过简单的操作,用户可以将心仪的花束加入购物车,方便随时查看已选鲜花和进行结算。

登录注册:为了提供个性化的购物服务,系统支持用户注册和登录功能,使用户能够轻松管理个人信息、查看订单历史等。

商品详情:用户可以查看每一款鲜花的详细信息,包括花材、花语等,以更好地了解并选择适合自己或送人的鲜花。

订单列表:用户可以方便地查看自己的订单历史,包括已完成和待处理的订单,提供了全面的订单管理功能。

下单:系统简化了下单流程,用户只需几步操作即可完成购物,享受快捷、愉悦的购物服务。

商品分类:通过合理的商品分类,用户可以迅速找到所需花卉,提高购物效率。

这个网上花店系统通过先进的前端设计,为用户打造了一个直观、美观的购物平台,使得选购鲜花成为一种愉快的体验。希望本系统能够为用户提供更多精彩的花卉选择,让鲜花的美好传递更加便捷、温馨。

一、运行环境

????????该系统采用了JDK 1.8作为基础开发环境,并搭建在JavaWeb框架上,利用Servlet、JSP等技术简化了Web应用程序的开发。作为数据存储后端,选择了MySQL数据库,并通过JDBC技术实现与数据库的交互,包括执行SQL查询和更新操作。JSP技术用于动态生成用户界面,将Java代码嵌入HTML页面,提供了更灵活、交互性更强的用户体验。这一组技术的有机结合使得系统具备了完整的Web开发能力,为用户提供高效、稳定的在线服务。

二、代码示例

代码如下(示例):

package com.itbaizhan.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.itbaizhan.bean.Dingdan;
import com.itbaizhan.bean.Fenlei;
import com.itbaizhan.bean.Gonggao;
import com.itbaizhan.bean.Product;
import com.itbaizhan.bean.User;
import com.itbaizhan.dao.DingdanDao;
import com.itbaizhan.dao.FenleiDao;
import com.itbaizhan.dao.GonggaoDao;
import com.itbaizhan.dao.ProductDao;
import com.itbaizhan.dao.UserDao;
import com.itbaizhan.util.Util;
import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;


//后台servlet,用于处理后台的所有请求1
public class ManageServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void init(ServletConfig config) throws ServletException {
		super.init(config);
	}
	
	
	public void destroy() {
		
		super.destroy();
	}


	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		//设置获取的参数的编码格式
		request.setCharacterEncoding("utf-8");
		
		//获取绝对地址
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
		//设置响应输出的字符串格式
		response.setCharacterEncoding("utf-8");response.setContentType("text/html; charset=utf-8");
		//获取输出对象
		PrintWriter writer = response.getWriter();
		//获取页面请求地址
		String uri = request.getRequestURI();	
		String[] s = uri.split("/");
		String method = s[3];
		
		//初始化跳转的地址
		String url ="";
		
		int pagenum =  1;//当前页
		int pagesize = 15;//每页显示的数量
		
		
		//初始化调用的数据库操作对象
		UserDao userDao = new UserDao();
		
		FenleiDao fenleiDao = new FenleiDao();
		
		ProductDao productDao = new ProductDao();
		
		GonggaoDao gonggaoDao = new GonggaoDao();
		
		DingdanDao dingdanDao = new DingdanDao();
		
		
		//用户登录
		if("login".equals(method)){
			//从jsp页面获取用户名和密码
			String username =  request.getParameter("username");
			String password =  request.getParameter("password");
			//查询用户名和密码是否匹配
			User bean = userDao.selectBean(" where username='"+username+"' and password ='"+password+"' and role=1 ");
			if(bean!=null){
				HttpSession session = request.getSession();
				session.setAttribute("manage", bean);
				
				writer.print("<script language='javascript'>alert('登录成功');window.location.href='"+basePath+"manage/index.jsp'; </script>");
			}else{
				
				writer.print("<script  language='javascript'>alert('用户名或者密码错误');window.location.href='"+basePath+"manage/login.jsp';</script>");
			}
		}
		
		//退出操作
		 else if("loginout".equals(method)){
			
			 HttpSession session  =request.getSession();
			 session.removeAttribute("manage");
			 writer.print("<script  language='javascript'>alert('退出成功');window.location.href='"+basePath+"manage/login.jsp';</script>");

		}
		
		//跳转到修改密码页面
		else if("passwordupdate".equals(method)){

				request.setAttribute("biaoti", "修改密码");
				request.setAttribute("url", "manageServlet/passwordupdate2");
				RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/passwordupdate.jsp");
				dispatcher.forward(request, response);
		}
			
			//修改密码操作
		else if("passwordupdate2".equals(method)){
				
				//从JSP获取信息
				String password1 = request.getParameter("password1");
				String password2 = request.getParameter("password2");
				HttpSession session = request.getSession();
				User user = (User)session.getAttribute("manage");
				
				User u = userDao.selectBean(" where username='"+user.getUsername()+"' and password='"+password1+"'  ");
				if(u!=null){
					u.setPassword(password2);
					userDao.updateBean(u);
					writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/passwordupdate'; </script>");
				}else{
					writer.print("<script  language='javascript'>alert('操作失败,原密码错误!');window.location.href='"+basePath+"manageServlet/passwordupdate'; </script>");
				}
				
				
				
		}
		
		
		
		//分类信息列表
		else if("fenleilist".equals(method)){
			
			//定义跳转的地址
			url = "manageServlet/fenleilist";
			
			//获取查询的信息
			String fname = request.getParameter("fname");	
			
			//组装查询的SQL语句
			StringBuffer sb = new StringBuffer();
			sb.append(" where  ");
			
			if(fname!=null&&!"".equals(fname)){
							
				sb.append(" fname like '%"+fname+"%' ");
				sb.append(" and ");
				
				request.setAttribute("fname", fname);
			}
			sb.append(" 1=1 order by id desc ");
			String where = sb.toString();

			//获取当前的页数
			if(request.getParameter("pagenum")!=null){
				pagenum = Integer.parseInt(request.getParameter("pagenum"));
			}

			//从数据库查询列表信息,带分页功能
			Map<String,List<Fenlei>> map = fenleiDao.getList(pagenum,pagesize,url,where);
			String pagerinfo = map.keySet().iterator().next();
			List<Fenlei> list = map.get(pagerinfo);
			
			//返回给jsp页面的信息
			request.setAttribute("pagerinfo", pagerinfo);
			request.setAttribute("list", list);
			request.setAttribute("biaoti", "分类信息列表");
			request.setAttribute("url", "manageServlet/fenleilist");
			request.setAttribute("url2", "manageServlet/fenlei");
			
			
			
			//定义跳转的地址
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/fenlei/fenleilist.jsp");
			//跳转操作
			dispatcher.forward(request, response);
		}
		
		
		//跳转到添加分类信息页面
		else if("fenleiadd".equals(method)){
			request.setAttribute("biaoti", "添加分类信息");
			request.setAttribute("url", "manageServlet/fenleiadd2");
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/fenlei/fenleiadd.jsp");
			dispatcher.forward(request, response);
		}
		
		//添加分类信息操作
		else if("fenleiadd2".equals(method)){

			//从JSP获取信息
			String fname = request.getParameter("fname");
			//定义对象
			Fenlei bean = new Fenlei();
			//设置对象的属性
			bean.setFname(fname);
			//插入数据库
			fenleiDao.insertBean(bean);
			//返回给JSP页面
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/fenleilist'; </script>");
		}
		
		//跳转到更新分类信息页面
		else if("fenleiupdate".equals(method)){
			
			//通过ID获取对象
			String id = request.getParameter("id");
			Fenlei bean = fenleiDao.selectBean(" where id= "+id);
			//把对象传给jsp页面
			request.setAttribute("bean", bean);
			request.setAttribute("biaoti", "更新分类信息");
			request.setAttribute("url", "manageServlet/fenleiupdate2?id="+bean.getId());
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/fenlei/fenleiupdate.jsp");
			dispatcher.forward(request, response);
		}
		
		//更新分类信息操作
		else if("fenleiupdate2".equals(method)){
			
			//从JSP获取信息
			String fname = request.getParameter("fname");
			//通过ID获取对象
			String id = request.getParameter("id");
			Fenlei bean = fenleiDao.selectBean(" where id= "+id);
			//更新对象属性
			bean.setFname(fname);
			//更新操作
			fenleiDao.updateBean(bean);
			
			
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/fenleilist'; </script>");
		}
		
		//删除分类信息操作
		else if("fenleidelete".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			Fenlei bean = fenleiDao.selectBean(" where id= "+id);
			//删除对象
			fenleiDao.deleteBean(bean);
			
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/fenleilist'; </script>");
		}
		
		//跳转到查看分类信息页面
		else if("fenleiupdate3".equals(method)){
			request.setAttribute("biaoti", "查看分类信息");
			//通过ID获取对象
			String id = request.getParameter("id");
			Fenlei bean = fenleiDao.selectBean(" where id= "+id);
			//把对象传给jsp页面
			request.setAttribute("bean", bean);
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/fenlei/fenleiupdate3.jsp");
			dispatcher.forward(request, response);
		}
		
		
		//商品信息列表
		else if("productlist".equals(method)){
			
			//定义跳转的地址
			url = "manageServlet/productlist";
			
			//获取查询的信息
			String fname = request.getParameter("fname");	
			request.setAttribute("fenleilist", fenleiDao.getList(""));
			String pname = request.getParameter("pname");	
			
			//组装查询的SQL语句
			StringBuffer sb = new StringBuffer();
			sb.append(" where  ");
			
			if(fname!=null&&!"".equals(fname)){
							
				sb.append(" fname like '%"+fname+"%' ");
				sb.append(" and ");
				
				request.setAttribute("fname", fname);
			}
			
			if(pname!=null&&!"".equals(pname)){
				
				sb.append(" pname like '%"+pname+"%' ");
				sb.append(" and ");
				
				request.setAttribute("pname", pname);
			}
			
			sb.append(" 1=1 order by id desc ");
			String where = sb.toString();

			//获取当前的页数
			if(request.getParameter("pagenum")!=null){
				pagenum = Integer.parseInt(request.getParameter("pagenum"));
			}

			//从数据库查询列表信息,带分页功能
			Map<String,List<Product>> map = productDao.getList(pagenum,pagesize,url,where);
			String pagerinfo = map.keySet().iterator().next();
			List<Product> list = map.get(pagerinfo);
			
			//返回给jsp页面的信息
			request.setAttribute("pagerinfo", pagerinfo);
			request.setAttribute("list", list);
			request.setAttribute("biaoti", "商品信息列表");
			request.setAttribute("url", "manageServlet/productlist");
			request.setAttribute("url2", "manageServlet/product");
			
			
			
			//定义跳转的地址
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/product/productlist.jsp");
			//跳转操作
			dispatcher.forward(request, response);
		}
		
		
		//跳转到添加商品信息页面
		else if("productadd".equals(method)){
			request.setAttribute("biaoti", "添加商品信息");
			request.setAttribute("url", "manageServlet/productadd2");
			request.setAttribute("fenleilist", fenleiDao.getList(""));
			
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/product/productadd.jsp");
			dispatcher.forward(request, response);
		}
		
		//添加商品信息操作
		else if("productadd2".equals(method)){

			
			//从JSP获取信息
			String fenleiid = request.getParameter("fenleiid");
			String jiage = request.getParameter("jiage");
			String miaoshu = request.getParameter("miaoshu");
			String pname = request.getParameter("pname");
			String count = request.getParameter("count");
			System.out.println("count=>"+count);
			
			Fenlei fenlei = fenleiDao.selectBean(" where id= "+fenleiid);
			//定义对象
			Product bean = new Product();
			//设置对象的属性
			bean.setCreatetime(Util.getTime());
			bean.setDianjishu(0);
			bean.setFenleiid(fenlei.getId()+"");
			bean.setFname(fenlei.getFname());
			bean.setJiage(Double.parseDouble(jiage));
			bean.setMiaoshu(miaoshu);
			bean.setPname(pname);
			bean.setTuijian("未推荐");
			bean.setXiaoliang(0);
			bean.setCount(Integer.parseInt(count));
			
			
			//插入数据库
			productDao.insertBean(bean);
			//返回给JSP页面
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/productlist'; </script>");
		}
		
		//跳转到更新商品信息页面
		else if("productupdate".equals(method)){
			
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			request.setAttribute("fenleilist", fenleiDao.getList(""));
			//把信息传给jsp页面
			request.setAttribute("bean", bean);
			request.setAttribute("biaoti", "更新商品信息");
			request.setAttribute("url", "manageServlet/productupdate2?id="+bean.getId());
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/product/productupdate.jsp");
			dispatcher.forward(request, response);
		}
		
		//更新商品信息操作
		else if("productupdate2".equals(method)){
			
			//从JSP获取信息
			String fenleiid = request.getParameter("fenleiid");
			String imgpath = request.getParameter("imgpath");
			String jiage = request.getParameter("jiage");
			String miaoshu = request.getParameter("miaoshu");
			String pname = request.getParameter("pname");
			String count = request.getParameter("count");

			Fenlei fenlei = fenleiDao.selectBean(" where id= "+fenleiid);
			
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			//更新对象属性
			bean.setFenleiid(fenlei.getId()+"");
			bean.setFname(fenlei.getFname());
			bean.setImgpath(imgpath);
			bean.setJiage(Double.parseDouble(jiage));
			bean.setMiaoshu(miaoshu);
			bean.setPname(pname);
			bean.setCount(Integer.parseInt(count));
			//更新操作
			productDao.updateBean(bean);
			
			
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/productlist'; </script>");
		}
		
		
		//跳转到上传商品图片页面
		else if("productupdate5".equals(method)){
			
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			//把信息传给jsp页面
			request.setAttribute("bean", bean);
			request.setAttribute("biaoti", "上传商品图片");
			request.setAttribute("url", "manageServlet/productupdate6?id="+bean.getId());
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/product/productupdate5.jsp");
			dispatcher.forward(request, response);
		}
		
		//上传商品图片操作
		else if("productupdate6".equals(method)){
			
			SmartUpload su = new SmartUpload();
			su.initialize(this.getServletConfig(), request, response);
			//限制上传文件的最大长度。
			su.setMaxFileSize(1500000*8);
			//设定允许上传的文件(通过扩展名限制)
			su.setAllowedFilesList("jpg,gif,bmp,JPG,GIF,BMP");
			String imgpath="";
			try {
				// 上传文件
				su.upload();
				// 将上传文件全部保存到指定目录
				com.jspsmart.upload.File file = su.getFiles().getFile(0);
				if (!file.isMissing())
				{

					//将附件以 当前时间+附件扩展名 作为文件名保存		
					java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
					String sNowTime = dateFormatter.format(new java.util.Date());
					imgpath = sNowTime+"."+ file.getFileExt();
					file.saveAs("/uploadfile/"+imgpath);
				}
			} catch (SmartUploadException e) {
				e.printStackTrace();
			}
			
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			//更新对象属性
			bean.setImgpath(imgpath);

			//更新操作
			productDao.updateBean(bean);
			
			
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/productlist'; </script>");
		}
		
		//删除商品信息操作
		else if("productdelete".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			//删除对象
			productDao.deleteBean(bean);
			
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/productlist'; </script>");
		}
		
		//推荐商品信息操作
		else if("productdelete2".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			bean.setTuijian("已推荐");
			
			productDao.updateBean(bean);
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/productlist'; </script>");
		}
		
		//删除商品信息操作
		else if("productdelete3".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			bean.setTuijian("未推荐");
			
			productDao.updateBean(bean);
			
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/productlist'; </script>");
		}
		
		//跳转到查看商品信息页面
		else if("productupdate3".equals(method)){
			request.setAttribute("biaoti", "查看商品信息");
			//通过ID获取对象
			String id = request.getParameter("id");
			Product bean = productDao.selectBean(" where id= "+id);
			//把对象传给jsp页面
			request.setAttribute("bean", bean);
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/product/productupdate3.jsp");
			dispatcher.forward(request, response);
		}
		
		
		
		//公告信息列表
		else if("gonggaolist".equals(method)){
			
			//定义跳转的地址
			url = "manageServlet/gonggaolist";
			
			//获取查询的信息
			String biaotibiaoti = request.getParameter("biaotibiaoti");	
			
			//组装查询的SQL语句
			StringBuffer sb = new StringBuffer();
			sb.append(" where  ");
			
			if(biaotibiaoti!=null&&!"".equals(biaotibiaoti)){
							
				sb.append(" biaoti like '%"+biaotibiaoti+"%' ");
				sb.append(" and ");
				
				request.setAttribute("biaoti", biaotibiaoti);
			}
			sb.append(" 1=1 order by id desc ");
			String where = sb.toString();

			//获取当前的页数
			if(request.getParameter("pagenum")!=null){
				pagenum = Integer.parseInt(request.getParameter("pagenum"));
			}

			//从数据库查询列表信息,带分页功能
			Map<String,List<Gonggao>> map = gonggaoDao.getList(pagenum,pagesize,url,where);
			String pagerinfo = map.keySet().iterator().next();
			List<Gonggao> list = map.get(pagerinfo);
			
			//返回给jsp页面的信息
			request.setAttribute("pagerinfo", pagerinfo);
			request.setAttribute("list", list);
			request.setAttribute("biaoti", "公告信息列表");
			request.setAttribute("url", "manageServlet/gonggaolist");
			request.setAttribute("url2", "manageServlet/gonggao");
			
			
			
			//定义跳转的地址
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/gonggao/gonggaolist.jsp");
			//跳转操作
			dispatcher.forward(request, response);
		}
		
		
		//跳转到添加公告信息页面
		else if("gonggaoadd".equals(method)){
			request.setAttribute("biaoti", "添加公告信息");
			request.setAttribute("url", "manageServlet/gonggaoadd2");
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/gonggao/gonggaoadd.jsp");
			dispatcher.forward(request, response);
		}
		
		//添加公告信息操作
		else if("gonggaoadd2".equals(method)){

			//从JSP获取信息
			String biaoti = request.getParameter("biaoti");
			String neirong = request.getParameter("neirong");
			//定义对象
			Gonggao bean = new Gonggao();
			//设置对象的属性
			bean.setBiaoti(biaoti);
			bean.setNeirong(neirong);
			bean.setShijian(Util.getTime());
			//插入数据库
			gonggaoDao.insertBean(bean);
			//返回给JSP页面
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/gonggaolist'; </script>");
		}
		
		//跳转到更新公告信息页面
		else if("gonggaoupdate".equals(method)){
			
			//通过ID获取对象
			String id = request.getParameter("id");
			Gonggao bean = gonggaoDao.selectBean(" where id= "+id);
			//把对象传给jsp页面
			request.setAttribute("bean", bean);
			request.setAttribute("biaoti", "更新公告信息");
			request.setAttribute("url", "manageServlet/gonggaoupdate2?id="+bean.getId());
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/gonggao/gonggaoupdate.jsp");
			dispatcher.forward(request, response);
		}
		
		//更新公告信息操作
		else if("gonggaoupdate2".equals(method)){
			
			//从JSP获取信息
			String biaoti = request.getParameter("biaoti");
			String neirong = request.getParameter("neirong");
			//通过ID获取对象
			String id = request.getParameter("id");
			Gonggao bean = gonggaoDao.selectBean(" where id= "+id);
			//更新对象属性
			bean.setBiaoti(biaoti);
			bean.setNeirong(neirong);
			//更新操作
			gonggaoDao.updateBean(bean);
			
			
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/gonggaolist'; </script>");
		}
		
		//删除公告信息操作
		else if("gonggaodelete".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			Gonggao bean = gonggaoDao.selectBean(" where id= "+id);
			//删除对象
			gonggaoDao.deleteBean(bean);
			
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/gonggaolist'; </script>");
		}
		
		//跳转到查看公告信息页面
		else if("gonggaoupdate3".equals(method)){
			request.setAttribute("biaoti", "查看公告信息");
			//通过ID获取对象
			String id = request.getParameter("id");
			Gonggao bean = gonggaoDao.selectBean(" where id= "+id);
			//把对象传给jsp页面
			request.setAttribute("bean", bean);
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/gonggao/gonggaoupdate3.jsp");
			dispatcher.forward(request, response);
		}
		
		
		
		//订单信息列表
		else if("dingdanlist".equals(method)){
			
			//定义跳转的地址
			url = "manageServlet/dingdanlist";
			
			//获取查询的信息
			String status = request.getParameter("status");	
			String orderid = request.getParameter("orderid");	
			
			//组装查询的SQL语句
			StringBuffer sb = new StringBuffer();
			sb.append(" where  ");
			
			if(orderid!=null&&!"".equals(orderid)){
							
				sb.append(" orderid like '%"+orderid+"%' ");
				sb.append(" and ");
				
				request.setAttribute("orderid", orderid);
			}
			
			if(status!=null&&!"".equals(status)){
				
				sb.append(" status like '%"+status+"%' ");
				sb.append(" and ");
				
				request.setAttribute("status", status);
			}
			sb.append(" 1=1 order by id desc ");
			String where = sb.toString();

			//获取当前的页数
			if(request.getParameter("pagenum")!=null){
				pagenum = Integer.parseInt(request.getParameter("pagenum"));
			}

			//从数据库查询列表信息,带分页功能
			Map<String,List<Dingdan>> map = dingdanDao.getList(pagenum,pagesize,url,where);
			String pagerinfo = map.keySet().iterator().next();
			List<Dingdan> list = map.get(pagerinfo);
			
			//返回给jsp页面的信息
			request.setAttribute("pagerinfo", pagerinfo);
			request.setAttribute("list", list);
			request.setAttribute("biaoti", "订单信息列表");
			request.setAttribute("url", "manageServlet/dingdanlist");
			request.setAttribute("url2", "manageServlet/dingdan");
			
			
			
			//定义跳转的地址
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/dingdan/dingdanlist.jsp");
			//跳转操作
			dispatcher.forward(request, response);
		}
		
		
		
		
		//处理订单信息操作
		else if("dingdandelete".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			Dingdan bean = dingdanDao.selectBean(" where id= "+id);
			
			bean.setStatus("已处理");
			dingdanDao.updateBean(bean);
			
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/dingdanlist'; </script>");
		}
		
		//跳转到查看订单信息页面
		else if("dingdanupdate3".equals(method)){
			request.setAttribute("biaoti", "查看订单信息");
			//通过ID获取对象
			String id = request.getParameter("id");
			Dingdan bean = dingdanDao.selectBean(" where id= "+id);
			//把对象传给jsp页面
			request.setAttribute("bean", bean);
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/dingdan/dingdanupdate3.jsp");
			dispatcher.forward(request, response);
		}
		
		
		//用户信息列表
		else if("userlist".equals(method)){
			
			//定义跳转的地址
			url = "manageServlet/userlist";
			
			//获取查询的信息
			String username = request.getParameter("username");	
	
			
			//组装查询的SQL语句
			StringBuffer sb = new StringBuffer();
			sb.append(" where  ");
			
			if(username!=null&&!"".equals(username)){
							
				sb.append(" username like '%"+username+"%' ");
				sb.append(" and ");
				
				request.setAttribute("username", username);
			}
			
			
			sb.append(" role=0 order by id desc ");
			String where = sb.toString();

			//获取当前的页数
			if(request.getParameter("pagenum")!=null){
				pagenum = Integer.parseInt(request.getParameter("pagenum"));
			}

			//从数据库查询列表信息,带分页功能
			Map<String,List<User>> map = userDao.getList(pagenum,pagesize,url,where);
			String pagerinfo = map.keySet().iterator().next();
			List<User> list = map.get(pagerinfo);
			
			//返回给jsp页面的信息
			request.setAttribute("pagerinfo", pagerinfo);
			request.setAttribute("list", list);
			request.setAttribute("biaoti", "用户信息列表");
			request.setAttribute("url", "manageServlet/userlist");
			request.setAttribute("url2", "manageServlet/user");
			
			
			
			//定义跳转的地址
			RequestDispatcher dispatcher = request.getRequestDispatcher("/manage/user/userlist.jsp");
			//跳转操作
			dispatcher.forward(request, response);
		}
		
		
		
		
		//删除用户信息操作
		else if("userdelete".equals(method)){
			//通过ID获取对象
			String id = request.getParameter("id");
			User bean = userDao.selectBean(" where id= "+id);
			
			userDao.deleteBean(bean);
			
		
			writer.print("<script  language='javascript'>alert('操作成功');window.location.href='"+basePath+"manageServlet/userlist'; </script>");
		}
		
		
		
	}

}

三、系统展示

网上花店首页:展示花店商品信息,可以通过名称和价格模糊查询。能够加入购物车、查看商品详情、观察价格以及库存数量、可以按照分类来查询商品。

网上花店详情页面:包含商品介绍、价格、点击次数、并且可以加入购物车。

订单详情页面:可以查看订单信息。

订单列表:查看历史订单

分类管理:维护分类信息。

订单管理:管理所有用户下单的订单信息。

商品管理:管理员可以在后台进行商品发布

系统公告:管理员可在后端发布公告通知。

用户管理:管理员可以对所有用户进行管理。

文章来源:https://blog.csdn.net/java18343246781/article/details/135224710
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。