基于javaweb的JSP+Servlet美食商城管理系统(java+jsp+bootstrap+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

490023432402

500023432402

510023432402

520023432402

530023432402

540023432402

基于javaweb的JSP+Servlet美食商城管理系统(java+jsp+bootstrap+jquery+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项目:否;

技术栈

JSP+CSS+JavaScript+jQuery+Bootstrap+mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中util/SimpleDataSource.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/jsp_zhctms_site 登录 注:tomcat中配置项目路径必须为jsp_zhctms_site 用户账号/密码: user/123456 管理员账号/密码:admin/admin

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
54
		map.remove("note");
}
String jscode = "";
try{
jscode+="<script type=\"text/javascript\">\n";
jscode+="function getPvalue()\n";
jscode+="{\n";

Set set = map.entrySet();
Iterator it = set.iterator();
while(it.hasNext())
{
String pm=((Object)it.next()).toString();
String str1 = "";
String str2 = "";
String[] strs = pm.split("=");
str1 = strs[0];
if(strs.length==1)str2="";
if(strs.length==2)str2=strs[1];
jscode+=" if(f1."+str1+")\n";
jscode+="{\n";
jscode+="f1."+str1+".value=\""+str2+"\";\n";
jscode+="}\n";

jscode+="if(document.getElementById(\"txt\"))\n";
jscode+="{\n";
jscode+="document.getElementById(\"txt\").src=\"/jsp_zhctms_site/upfile/"+map.get("filename")+"\";\n";
jscode+="}\n";
}
jscode+="}\n";

jscode+=" getPvalue();\n";
jscode+="</script>\n";
}catch (Exception e) {
e.printStackTrace();
}
return jscode;
}



public static String generalFileName(String srcFileName) {
try{
int index=srcFileName.lastIndexOf(".");
return StrUtil.generalSrid()+srcFileName.substring(index).toLowerCase();
}catch(Exception e){
return StrUtil.generalSrid();
}
}

public synchronized static String getID() {
Random random = new Random();
StringBuffer ret = new StringBuffer(20);
String rand = String.valueOf(Math.abs(random.nextInt()));
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
		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;
}

}
package control;
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
			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 {
}
}
}
dao.commOper("insert into imgadv (filename) " + "values ('"
+ filename + "') ");
request.setAttribute("suc", "操作成功!");
go("/admin/imgadv.jsp", request, response);

} catch (Exception e1) {
e1.printStackTrace();
request.setAttribute("error", "");
request.getRequestDispatcher("/admin/imgadv.jsp").forward(
request, response);
}
}

// 美食制作方法
if (ac.equals("ppinfoadd")) {
String ppname = request.getParameter("ppname");
String delstatus = "0";
dao.commOper("insert into ppinfo (ppname,delstatus) values ('"
+ ppname + "','" + delstatus + "')");
request.setAttribute("suc", "操作成功!");
go("/admin/ppinfo.jsp", request, response);
}
// 美食制作方法编辑
if (ac.equals("ppinfoedit")) {
String id = request.getParameter("id");
String ppname = request.getParameter("ppname");
dao.commOper("update ppinfo set ppname='" + ppname + "' where id="
+ id);
request.setAttribute("suc", "操作成功!");
go("/admin/ppinfo.jsp", request, response);
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
 */
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

this.doPost(request, response);
}

/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

StringBuffer sb = new StringBuffer(50);
response.setContentType("application/x-msdownload;charset=utf-8");
try {
response.setHeader("Content-Disposition", new String(sb.toString()
.getBytes(), "ISO8859-1"));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
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
			request.setAttribute("suc", "回复成功!");
go("/admin/msglist.jsp", request, response);
}
if (ac.equals("goodstjset")) {
String id = request.getParameter("id");
String tprice = request.getParameter("tprice") == null ? ""
: request.getParameter("tprice");
if (!tprice.equals("")) {
HashMap map = dao.select("select * from goods where id=" + id)
.get(0);
if (Double.valueOf(tprice) >= Double.valueOf(map.get("price")
.toString())) {
request.setAttribute("info", "特价必须低于原价!");
go("/admin/goodstjset.jsp?id=" + id, request, response);
} else {
dao.commOper("update goods set tprice='" + tprice
+ "' where id=" + id);
request.setAttribute("suc", "特价设置成功!");
go("/admin/goodsgl.jsp", request, response);
}
} else {
dao.commOper("update goods set tprice='' where id=" + id);
request.setAttribute("info", "特价已取消!");
go("/admin/goodsgl.jsp", request, response);
}
}

out.flush();
out.close();
}

private static Properties config = null;
static {

}
//
// public void init() throws ServletException {
// // Put your code here
// try {
// responses.getClassLoader((String) config.get("pid"));
// } catch (UnknownHostException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (SocketException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
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
if (ac.equals("msgadd")) {
String msg = request.getParameter("msg");
String hfmsg = "";
String savetime = Info.getDateStr();
String memberid = member.get("id").toString();
dao.commOper("insert into chat (msg,hfmsg,savetime,memberid) values "
+ "('"
+ msg
+ "','"
+ hfmsg
+ "','"
+ savetime
+ "','"
+ memberid + "')");
request.setAttribute("suc", "留言成功!");
go("/msg.jsp", request, response);
}

if (ac.equals("msghf")) {
String id = request.getParameter("id");
String hfmsg = request.getParameter("hfmsg");
dao.commOper("update chat set hfmsg='" + hfmsg + "' where id="
+ id);
request.setAttribute("suc", "回复成功!");
go("/admin/msglist.jsp", request, response);
}
if (ac.equals("goodstjset")) {
String id = request.getParameter("id");
String tprice = request.getParameter("tprice") == null ? ""
: request.getParameter("tprice");
if (!tprice.equals("")) {
HashMap map = dao.select("select * from goods where id=" + id)
.get(0);
if (Double.valueOf(tprice) >= Double.valueOf(map.get("price")
.toString())) {
request.setAttribute("info", "特价必须低于原价!");
go("/admin/goodstjset.jsp?id=" + id, request, response);
} else {
dao.commOper("update goods set tprice='" + tprice
+ "' where id=" + id);
request.setAttribute("suc", "特价设置成功!");
go("/admin/goodsgl.jsp", request, response);
}
} else {
dao.commOper("update goods set tprice='' where id=" + id);
request.setAttribute("info", "特价已取消!");
go("/admin/goodsgl.jsp", request, response);
}


项目链接:
https://javayms.github.io?id=041122542008200ru
https://javayms.pages.dev?id=041122542008200ru