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






基于javaweb的JSP+Servlet零食商城系统(java+jsp+javascript+servlet+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版本; 6.是否Maven项目:否;
技术栈
- 后端:Servlet 2. 前端:JSP+CSS+JavaScript+ajax
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中dbconnection.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/foodemarket 登录
——————————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
| String cheph = request.getParameter("cheph"); String jiaoflx = request.getParameter("jiaoflx"); String shoufdw = request.getParameter("shoufdw"); String jiaofh = request.getParameter("jiaofh"); String jiaofsj = request.getParameter("jiaofsj"); String jiaofje = request.getParameter("jiaofje"); String jiasy = request.getParameter("jiasy"); String xiacjfsj = request.getParameter("xiacjfsj"); String bei = request.getParameter("bei"); String sql="insert into jfinfo values( '"+cheph+"','"+jiaoflx+"','"+shoufdw+"','"+jiaofh+"','"+jiaofsj+"','"+jiaofje+"','"+jiasy+"','"+xiacjfsj+"','"+bei+"','"+date+"')" ; System.out.println(sql); dao.commOper(sql); go("/admin/jfjl.jsp", request, response); }
if(ac.equals("upjfjl")) { String id = request.getParameter("id"); String cheph = request.getParameter("cheph"); String jiaoflx = request.getParameter("jiaoflx"); String shoufdw = request.getParameter("shoufdw"); String jiaofh = request.getParameter("jiaofh"); String jiaofsj = request.getParameter("jiaofsj"); String jiaofje = request.getParameter("jiaofje"); String jiasy = request.getParameter("jiasy"); String xiacjfsj = request.getParameter("xiacjfsj"); String bei = request.getParameter("bei"); String sql="update jfinfo set cheph='"+cheph+"',jiaoflx='"+jiaoflx+"',shoufdw='"+shoufdw+"',jiaofh='"+jiaofh+"',jiaofsj='"+jiaofsj+"',jiaofje='"+jiaofje+"',jiasy='"+jiasy+"',xiacjfsj='"+xiacjfsj+"',bei='"+bei+"' where id="+id ; System.out.println(sql); dao.commOper(sql); go("/admin/jfjl.jsp", request, response); }
if(ac.equals("addlsjl")) { String cheph = request.getParameter("cheph"); String liansdj = request.getParameter("liansdj");
|
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
| if (j == i) { thePics1.append(url.replaceAll("\n", "")); theLinks1.append("xiang.jsp?id=" + b.get("id")); theTexts1.append(title); }
} thePics1.append("';");
theLinks1.append("';"); theTexts1.append("';"); imgStr.append(thePics1 + "\n"); imgStr.append(theLinks1 + "\n"); imgStr.append(theTexts1 + "\n"); imgStr.append("\n setPic(thePics1,theLinks1,theTexts1," + width + "," + height + ",'picViwer1');</script>"); return imgStr.toString(); } public HashMap getmap(String id, String table) { List<HashMap> list = new ArrayList(); try { Statement st = conn.createStatement(); System.out.println("select * from " + table + " where id=" + id); ResultSet rs = st.executeQuery("select * from " + table + " where id=" + id); ResultSetMetaData rsmd = rs.getMetaData(); while (rs.next()) { HashMap map = new HashMap(); int i = rsmd.getColumnCount(); for (int j = 1; j <= i; j++) { if (!rsmd.getColumnName(j).equals("ID")) { String str = rs.getString(j) == null ? "" : rs.getString(j); if (str.equals("null")) str = ""; map.put(rsmd.getColumnName(j), str); } else map.put("id", rs.getString(j)); } list.add(map); } rs.close(); st.close();
|
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
| 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()); filename = Info.generalFileName(fullFile.getName()); File newFile = new File(request.getRealPath("/upfile/")+"/" + filename); try { fileItem.write(newFile); } catch (Exception e) { e.printStackTrace(); } }else{ } } } go("/js/uploadimg.jsp?filename="+filename, request, response); } catch (Exception e1) { e1.printStackTrace(); } } dao.close(); out.flush(); out.close(); }
public void init() throws ServletException {
|
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
| String sql="insert into qtsrinfo values( '"+cheph+"'," + "'"+shourlx+"'," + "'"+shoursj+"'," + "'"+shourje+"'," + "'"+jiasy+"'," + "'"+bei+"'," + "'"+date+"')" ; System.out.println(sql); dao.commOper(sql); go("/admin/qtsr.jsp", request, response); }
if(ac.equals("upqtsr")) { String id = request.getParameter("id"); String cheph = request.getParameter("cheph"); String shourlx = request.getParameter("shourlx"); String shoursj = request.getParameter("shoursj"); String shourje = request.getParameter("shourje"); String jiasy = request.getParameter("jiasy"); String bei = request.getParameter("bei"); String sql="update qtsrinfo set cheph= '"+cheph+"'," + "shourlx='"+shourlx+"'," + "shoursj='"+shoursj+"'," + "shourje='"+shourje+"'," + "jiasy='"+jiasy+"'," + "bei='"+bei+"' where id='"+id+"'" ; System.out.println(sql); dao.commOper(sql); go("/admin/qtsr.jsp", request, response); }
if(ac.equals("adduser")) { String uname = request.getParameter("uname"); String upass = request.getParameter("upass"); String utype = request.getParameter("utype"); int i = dao.getInt("select count(*) from sysuser where uname='"+uname+"'"); if(i==0) { String sql = "insert into sysuser values('"+uname+"','"+upass+"','"+date+"','"+utype+"')";
|
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
| PrintWriter wrt = null; try { wrt = response.getWriter(); } catch (IOException e) { e.printStackTrace(); } wrt.write(str); } return ""; }
public int getInt(String sql) { int i = 0; try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); if (rs.next()) { i = rs.getInt(1); } st.close(); } catch (SQLException e) { e.printStackTrace(); } return i; }
public double getDouble(String sql) { double i = 0; try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); if (rs.next()) { i = rs.getDouble(1);
} st.close(); } catch (SQLException e) { e.printStackTrace(); } return i; }
public void commOper(String sql) { try { Statement st = conn.createStatement();
|
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
| // } 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 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>");
} buf.append("</select>"); this.info = buf.toString(); }
public Collection getCollection() { return collection; }
public long getCount() { return count; }
public int getCurrentPage() { return currentPage; }
public long getPageNumber() { return pageNumber; }
public int getPageSize() { return pageSize; }
public String getInfo() { return info; }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=221122542008200sk
https://javayms.pages.dev?id=221122542008200sk