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






基于javaweb的JSP+Servlet球队nba及其周边商城系统(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文件名称的数据库,并导入项目的sql文件;
使用IDEA/Eclipse/MyEclipse导入项目;
将项目中util/SimpleDataSource.java配置文件中的数据库配置改为自己的配置;
运行项目,输入localhost:8080/jsp_zhctms_site 登录 注:tomcat中配置项目路径必须为jsp_zhctms_site
用户账号/密码: 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| // 订单发货 if (ac.equals("ddfh")) { String ddid = request.getParameter("ddid"); String wlcompany = request.getParameter("wlcompany"); String wlno = request.getParameter("wlno"); String wlinfo = wlcompany + "<br/>" + wlno; // 查询订单及订单详情表 HashMap ddmap = dao.select("select * from ddinfo where id=" + ddid) .get(0); ArrayList<HashMap> dddetaillist = (ArrayList<HashMap>) dao .select("select * from dddetail where ddno=" + ddmap.get("ddno")); boolean flag = true;// 用作订单商品库存校验结果 for (HashMap dddetailmap : dddetaillist) { // 如果其中某个商品的数量大于其库存量 则置 FLASE标识 if (Integer.valueOf(dddetailmap.get("sl").toString()) > Info .getkc(dddetailmap.get("goodid").toString())) { flag = false; } } if (flag) { dao.commOper("update ddinfo set fhstatus='已发货',wlinfo='" + wlinfo + "' where id=" + ddid); // 发货后减库存 for (HashMap dddetailmap : dddetaillist) { dao.commOper("insert into kcrecord (gid,happennum,type,savetime) values " + "('" + dddetailmap.get("goodid") + "','" + dddetailmap.get("sl") + "','out','" + Info.getDateStr() + "')"); }
request.setAttribute("info", "订单已发货!"); go("/admin/ddgl.jsp", request, response); } else { request.setAttribute("info", "订单中商品库存不足,发货失败!"); go("/admin/ddgl.jsp", request, response); } }
// 会员注册 if (ac.equals("register")) { String uname = request.getParameter("username"); String upass = request.getParameter("upass"); String email = request.getParameter("email") == null ? "" : request .getParameter("email"); String tname = request.getParameter("tname") == null ? "" : request .getParameter("tname"); String sex = request.getParameter("sex") == null ? "" : request .getParameter("sex"); String addr = request.getParameter("addr") == null ? "" : request
|
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 42 43 44 45 46 47
| buf.append(" "); if (this.currentPage < this.pageNumber) { buf.append("<a href='").append(this.path).append("¤tPage=") .append(currentPage + 1).append(parameter).append( "' class='ls'>").append("下页") .append("</a>"); } else {
buf.append("下页");
}
buf.append(" "); if (this.currentPage == this.pageNumber) buf.append("末页 "); else buf.append("<a href='").append(this.path).append("¤tPage=") .append(this.pageNumber).append(parameter).append( "' class='ls'>").append("末页") .append("</a></font> "); // //////////////////// // for (int i = 0; i < this.pageNumber; i++) { // if (this.currentPage == i + 1) { // buf.append("<font color=red>[" + (i + 1) + "]</font>").append( // " "); // } else { // buf.append("<a href='").append(this.path).append( // "¤tPage=").append(i + 1).append(parameter) // .append("' style='TEXT-DECORATION:none'>").append( // "[" + (i + 1) + "]").append("</a> "); // }
// } buf.append("<select class='input-xlarge' onchange=\"javascript:window.location='").append( this.path).append("¤tPage='+").append( "this.options[this.selectedIndex].value").append(parameter) .append("\">"); for (int i = 0; i < this.pageNumber; i++) { if (this.currentPage == i + 1) buf.append("<option value=" + (i + 1) + " selected=\"selected\">" + (i + 1) + "</option>"); else buf.append("<option value=" + (i + 1) + ">" + (i + 1) + "</option>");
}
|
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
| public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); }
MainMethod responses = new MainMethod();
public void go(String url, HttpServletRequest request, HttpServletResponse response) { try { request.getRequestDispatcher(url).forward(request, response); } catch (ServletException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void gor(String url, HttpServletRequest request, HttpServletResponse response) { try { response.sendRedirect(url); } catch (IOException e) { e.printStackTrace(); }
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); HashMap admin = (HashMap) session.getAttribute("admin"); HashMap member = (HashMap) session.getAttribute("member"); String ac = request.getParameter("ac"); if (ac == null) ac = ""; CommDAO dao = new CommDAO(); String date = Info.getDateStr();
|
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 42 43 44 45 46 47 48 49 50 51 52 53
| ArrayList cklist = (ArrayList) dao.select(cksql); if (imgtype.equals("banner") && cklist.size() != 0) { request.setAttribute("no", ""); go("/admin/imgadvadd.jsp", request, response); } else { String sql = "insert into imgadv (filename,imgtype) " + "values('" + img + "','" + imgtype + "')"; dao.commOper(sql); request.setAttribute("suc", ""); go("/admin/imgadvadd.jsp", request, response); } } catch (Exception e1) { e1.printStackTrace(); request.setAttribute("no", ""); request.getRequestDispatcher("/admin/imgadvadd.jsp").forward( request, response); } }
if (ac.equals("imgadvedit")) { String id = request.getParameter("id"); HashMap map = dao.select("select * from imgadv where id=" + id) .get(0); try { String img = map.get("filename").toString(); request.setCharacterEncoding("utf-8"); RequestContext requestContext = new ServletRequestContext( request); if (FileUpload.isMultipartContent(requestContext)) {
DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setRepository(new File(request .getRealPath("/upfile/") + "/")); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(100 * 1024 * 1024); List items = new ArrayList(); items = upload.parseRequest(request);
FileItem fileItem = (FileItem) items.get(0); if (fileItem.getName() != null && fileItem.getSize() != 0) { if (fileItem.getName() != null && fileItem.getSize() != 0) { File fullFile = new File(fileItem.getName()); img = Info.generalFileName(fullFile.getName()); File newFile = new File( request.getRealPath("/upfile/") + "/" + img); try { fileItem.write(newFile); } catch (Exception e) { e.printStackTrace(); } } else { }
|
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 42 43 44 45 46
| if(inlist.size()>0){ for(HashMap inmap:inlist){ innum += Integer.parseInt(inmap.get("happennum").toString()); } } if(outlist.size()>0){ for(HashMap outmap:outlist){ outnum += Integer.parseInt(outmap.get("happennum").toString()); } } znum = innum - outnum; return znum; } }
package util;
public class PageManager { private PageManager() {
}
public static final int DEFAULTPAGESIZE = 20;
public static final int segment = 10;
protected int currentPage;
protected int pageSize;
protected long pageNumber;
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=041023491103200xj
https://javayms.pages.dev?id=041023491103200xj