基于javaweb的JSP+Servlet汽配商城系统(java+servlet+javascript+jsp+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

340023412402

350023412402

370023412402

380023412402

390023412402

400023412402

基于javaweb的JSP+Servlet汽配商城系统(java+servlet+javascript+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版本;

技术栈

HTML+CSS+JavaScript+jsp+mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/login.jsp 登录

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
			     }
}
}

go("/js/uploadimg5.jsp?filename="+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
}
}


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


public void init() throws ServletException {
// Put your code here
}

public static void main(String[] args) {
System.out.println("11111111");
}

}
package dao;




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
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txt height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename\" id=\"filename\" value=\"\" />";
return jscode;
}



public static String getImgUpInfo2(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg2()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txt2 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename2\" id=\"filename2\" value=\"\" />";
return jscode;
}

public static String getImgUpInfo3(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg3()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txt3 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename3\" id=\"filename3\" value=\"\" />";
return jscode;
}

public static String getImgUpInfo4(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg4()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txt4 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename4\" id=\"filename4\" value=\"\" />";
return jscode;
}

public static String getImgUpInfo5(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg5()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txt5 height=\""+height+"\"/>";
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
      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()));
ret.append(getDateStr());
ret.append(rand.substring(0,6));

return ret.toString();
}



public static String getImgUpInfoExt(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txtext height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename\" id=\"filename\" value=\"\" />";
return jscode;
}

public static String getImgUpInfo(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" onclick=\"uploadimg()\" src=\"/jsp_qipei_shop/js/nopic.jpg\" id=txt height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename\" id=\"filename\" value=\"\" />";
return jscode;
}
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
 * @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 {


try {
String proname ="";
String cpcj ="";
String cand ="";
String protype ="";
String mprice ="";
String price ="";
String tgrs ="";
String discount = "";
String kucun ="";
String yujin ="";
String filename="";
String content ="";
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);

proname = Info.getUTFStr(((FileItem) items.get(0)).getString()) ;
cpcj = Info.getUTFStr(((FileItem) items.get(1)).getString()) ;
cand = Info.getUTFStr(((FileItem) items.get(2)).getString()) ;
protype = Info.getUTFStr(((FileItem) items.get(3)).getString()) ;
mprice = Info.getUTFStr(((FileItem) items.get(4)).getString()) ;
price = Info.getUTFStr(((FileItem) items.get(5)).getString()) ;
tgrs = Info.getUTFStr(((FileItem) items.get(6)).getString()) ;
discount = Info.getUTFStr(((FileItem) items.get(7)).getString()) ;
kucun = Info.getUTFStr(((FileItem) items.get(8)).getString()) ;
yujin = Info.getUTFStr(((FileItem) items.get(9)).getString()) ;
content = Info.getUTFStr(((FileItem) items.get(11)).getString()) ;

FileItem fileItem = (FileItem) items.get(10);
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




public class MainCtrl extends HttpServlet {

public MainCtrl() {
super();
}

public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

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

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) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
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
						dao.commOper(isql);
}catch (Exception e) {
continue;
}

}
workbook.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
go("/admin/"+page+"?docname="+filename, request, response);
} catch (Exception e1) {
e1.printStackTrace();
}
}


if(ac.equals("uploadimg"))
{
try {
String filename="";
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());
filename = Info.generalFileName(fullFile.getName());
File newFile = new File(request.getRealPath("/upfile/")+"/" + filename);
try {
fileItem.write(newFile);
} catch (Exception e) {
e.printStackTrace();
}
}else{
}


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