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






基于javaweb的JSP+Servlet维他茶饮商城系统(java+jdbc+servlet+jsp+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项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
技术栈
Servlet、JSP、JDBC、MySQL5.7、Tomcat8
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
将项目中com/hr/dao/Basedao.java配置文件中的数据库配置改为自己的配置;
运行项目,输入localhost:8080/jsp_vtacha_shop
用户账号/密码: user/123456
管理员账号/密码: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
|
public class gmServlet extends HttpServlet { @Override protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { arg1.setContentType("text/html;charset=utf-8"); PrintWriter out=arg1.getWriter(); EncodeUtil.encode(arg0); HttpSession session=arg0.getSession(); EASYBUY_USER list=(EASYBUY_USER)session.getAttribute("name"); String id=list.getEU_USER_ID(); String name=list.getEU_USER_NAME(); String address=list.getEU_ADDRESS(); String price=arg0.getParameter("jstext"); String [] EP_ID=arg0.getParameterValues("spID"); String [] quantity=arg0.getParameterValues("number"); String [] sPPrice=arg0.getParameterValues("sPPrice"); for(int i=0;i<EP_ID.length;i++){ int count5=ESDao.updateStock(Integer.parseInt(quantity[i]),Integer.parseInt(EP_ID[i])); } int [] pprice=new int[EP_ID.length];
|
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
| } } }
public class RegisterInServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); String username=req.getParameter("userName"); String name=req.getParameter("name"); String rePassWord=req.getParameter("rePassWord"); String sex=req.getParameter("sex"); String year=req.getParameter("birthday"); String email=req.getParameter("email"); String mobile=req.getParameter("mobile"); String address=req.getParameter("address"); String veryCode=req.getParameter("veryCode"); HttpSession session = req.getSession(); String sysCode = (String)session.getAttribute("syscode"); EASYBUY_USER u=new EASYBUY_USER(username, name, rePassWord, sex, year, null, email, mobile, address, 1); int count=EASYBUY_USERDao.insert(u); PrintWriter out=resp.getWriter(); if(sysCode.equals(veryCode)){
|
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
| // es_EU_USER_ID NVARCHAR2(30),--用户id // es_valid NUMBER --是否结账,1未结账,2已结账 EASYBUY_PRODUCT p = null; String pid = req.getParameter("id"); String count = req.getParameter("count"); if(pid!=null){ p = EASYBUY_PRODUCTDao.selectById(Integer.parseInt(pid)); } resp.setContentType("text/html;charset=utf-8"); PrintWriter out = resp.getWriter(); HttpSession session = req.getSession(); EASYBUY_USER user=(EASYBUY_USER)session.getAttribute("name"); if(user!=null){ // System.out.println("登录好了"); EASYBUY_USER eu=(EASYBUY_USER)session.getAttribute("name"); String id=(String)eu.getEU_USER_ID(); ArrayList<eb_shop> list=ESDao.getShop(id); req.setAttribute("shoplist",list); //req.getRequestDispatcher("shopping.jsp").forward(req, resp); }else{ out.print("<script>"); out.print("alert('请先登录');"); out.print("location.href='login.jsp';"); out.print("</script>"); out.close(); return; } String uid = user.getEU_USER_ID(); int valid = 1; eb_shop sp = new eb_shop(0, p.getEP_FILE_NAME(), p.getEP_NAME(), p.getEP_PRICE(), Integer.parseInt(count), p.getEP_STOCK(), p.getEP_ID(), uid, valid); int epid=p.getEP_ID(); ESDao.insert(sp); resp.sendRedirect("selectProductView?id="+epid); //req.getRequestDispatcher("selectProductView?id=").forward(req, resp); } }
|
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
| } }else{ PrintWriter out = resp.getWriter(); out.print("<script>"); out.print("alert('用户名或密码错误');"); out.print("location.href='login.jsp';"); out.print("</script>"); out.close(); } }else{ PrintWriter out = resp.getWriter(); out.print("<script>"); out.print("alert('验证码错误');"); out.print("location.href='login.jsp';"); out.print("</script>"); out.close(); } } }
public class IndexSelectServlet extends HttpServlet { @SuppressWarnings("unchecked") @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //查询分类数据 ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather(); req.setAttribute("flist", flist); ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild(); req.setAttribute("clist", clist); ArrayList<EASYBUY_PRODUCT> tlist = EASYBUY_PRODUCTDao.selectAllByT(); req.setAttribute("tlist", tlist);
|
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
|
public class SelectProductViewServlet extends HttpServlet { @SuppressWarnings("unchecked") @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather(); req.setAttribute("flist", flist); ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild(); req.setAttribute("clist", clist); String id = req.getParameter("id"); HttpSession session = req.getSession(); ArrayList<Integer> ids = (ArrayList<Integer>)session.getAttribute("ids"); if(ids==null){ ids = new ArrayList<Integer>(); } if(ids.size()>=5){ ids.remove(0); } if(id!=null&&(!ids.contains(Integer.parseInt(id)))){ ids.add(Integer.parseInt(id)); } session.setAttribute("ids", ids); ids = (ArrayList<Integer>) session.getAttribute("ids"); if(ids!=null){ ArrayList<EASYBUY_PRODUCT> lastlylist = EASYBUY_PRODUCTDao.selectById(ids); req.setAttribute("lastlylist", lastlylist); }
|
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
| Integer.parseInt(stock), Integer.parseInt(pid.split("-")[0]), Integer.parseInt(pid.split("-")[1]), fname); int count = 0; if(p!=null){ count = EASYBUY_PRODUCTDao.update(p); } req.getRequestDispatcher("productSelect").forward(req, resp); } }
public class DoProductAddServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { SmartUpload su = new SmartUpload(); su.initialize(this.getServletConfig(), req, resp); try { su.upload(); } catch (SmartUploadException e) { e.printStackTrace(); } Files fs = su.getFiles(); File f = fs.getFile(0);
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=101023501103200zq
https://javayms.pages.dev?id=101023501103200zq