当前位置:首页 > 代码 > 正文

网上商城jsp代码(网上商城jsp代码大全)

admin 发布:2022-12-19 22:34 179


今天给各位分享网上商城jsp代码的知识,其中也会对网上商城jsp代码大全进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

求简单实现网上商城功能的java代码

平时在线10k人大概是让你创建一个数据库连接池,大小设置10k。

下面是一个图书商城的数据库表部分,供你参考

set utf8

DROP TABLE IF EXISTS d_product;

CREATE TABLE d_product (//用来存放总商品,入图书种类

id int(12) NOT NULL auto_increment,

product_name varchar(100) NOT NULL,

description varchar(100) default NULL,

add_time bigint(20) default NULL,

fixed_price double NOT NULL,

dang_price double NOT NULL,

keywords varchar(200) default NULL,

has_deleted int(1) NOT NULL default '0',

product_pic varchar(200) default NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO d_product VALUES (23,'上课睡觉的故事','上课睡觉的故事',1237873000234,200,180,'key',0,'15.jpg');

DROP TABLE IF EXISTS d_book;

CREATE TABLE d_book (//用来存放图书的具体内容

id int(12) NOT NULL,

author varchar(200) NOT NULL,

publishing varchar(200) NOT NULL,

publish_time bigint(20) NOT NULL,

word_number varchar(15) default NULL,

which_edtion varchar(15) default NULL,

total_page varchar(15) default NULL,

print_time int(20) default NULL,

print_number varchar(15) default NULL,

isbn varchar(25) default NULL,

author_summary text NOT NULL,

catalogue text NOT NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO d_book VALUES (24,'阿斗,'地球出版社',1237873000234,'1万','1','100',1,NULL,'12345678','无描述,'好书!');

DROP TABLE IF EXISTS d_category;

CREATE TABLE d_category (//商城图书目录

id int(12) NOT NULL auto_increment,

turn int(10) NOT NULL,

en_name varchar(200) NOT NULL,

name varchar(200) NOT NULL,

description varchar(200),

parent_id int(10),

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO d_category VALUES (1,1,'Book','图书',NULL,0);

DROP TABLE IF EXISTS d_category_product;

CREATE TABLE d_category_product (//这个是连接目录和书籍具体信息的表

id int(12) NOT NULL auto_increment,

product_id int(10) NOT NULL,

cat_id int(10) NOT NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO d_category_product VALUES (72,24,1);

DROP TABLE IF EXISTS d_item;

CREATE TABLE d_item (//这个订单条目表

id int(12) NOT NULL auto_increment,

order_id int(10) NOT NULL,

product_id int(10) NOT NULL,

product_name varchar(100) NOT NULL,

dang_price double NOT NULL,

product_num int(10) NOT NULL,

amount double NOT NULL,

PRIMARY KEY (id)

)

DROP TABLE IF EXISTS d_order;

CREATE TABLE d_order (//订单表

id int(10) NOT NULL auto_increment,

user_id int(10) NOT NULL,

status int(10) NOT NULL,

order_time bigint(20) NOT NULL,

order_desc varchar(100) default NULL,

total_price double NOT NULL,

receive_name varchar(100) default NULL,

full_address varchar(200) default NULL,

postal_code varchar(8) default NULL,

mobile varchar(20) default NULL,

phone varchar(20) default NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB;

DROP TABLE IF EXISTS d_receive_address;

CREATE TABLE d_receive_address (//收件人信息表

id int(12) NOT NULL auto_increment,

user_id int(11) NOT NULL,

receive_name varchar(20) NOT NULL,

full_address varchar(200) NOT NULL,

postal_code varchar(8) NOT NULL,

mobile varchar(15) default NULL,

phone varchar(20) default NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB;

insert into d_receive_address values(1, 6,'Java','sun.cn','10000800','12345','67890');

insert into d_receive_address values(2, 6,'JavaJavaJava','ibm.cn','10000600','12345','67890');

DROP TABLE IF EXISTS d_user;

CREATE TABLE d_user (//用户表,用户信息

id int(12) NOT NULL auto_increment,

email varchar(50) NOT NULL,

nickname varchar(50) default NULL,

password varchar(50) NOT NULL,

user_integral int(12) NOT NULL default '0',

is_email_verify char(3),

email_verify_code varchar(50) default NULL,

last_login_time bigint default NULL,

last_login_ip varchar(15) default NULL,

PRIMARY KEY (id),

UNIQUE KEY email (email)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

你好 请问有jsp做的网上商城的成功代码么

我有~ 呵呵 可以给你一个 说不上是成功 就是学习用的 有需要可以加群

程序员之家:84735131

在线购物商品分类jsp,java代码怎么写,有父类子类的?

N种办法

1、mybatis 配置文件 写SQL 解决

2、通过JAVA service 通过父类信息查询子类并封装

3、提供一个接口,前台二级联动方式,点第一个给后台传值0 ,查询父ID为0 的 当点击第二个联动的时候 把第一个信息的ID 给你传过去,如 电子数码ID 为1 那就传1 后台还是根据父类查询,也就是 父类ID 1 这样就查出 所对应的 子类信息了。

jsp网上购物代码及操作!

1.index.jsp登陆界面:

%@ page language="java" import="java.util.*" pageEncoding="GB2312"%

%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%

%session.invalidate();% %--销毁所有session对象--%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

base href="%=basePath%"

title购物车/title

meta http-equiv="pragma" content="no-cache"

meta http-equiv="cache-control" content="no-cache"

meta http-equiv="expires" content="0"

meta http-equiv="keywords" content="keyword1,keyword2,keyword3"

meta http-equiv="description" content="This is my page"

!--

link rel="stylesheet" type="text/css" href="styles.css"

--

/head

body

center

hr

请输入用户名,默认的为Guest

form action="checklogin.jsp" mothod=get

table width="40%" border="1"

tr bgcolor="#336600"

tddiv align="center"font color="FFFFFF"用户登陆/font/div/td

/tr

tr align="center" bgcolor="#CCCCCC"

td用户名:input type="password" name="userID"/td

/tr

tr align="center" bgcolor="#CCCCCC"

td口  令:input type="password" name="password"/td

/tr

tr align="center" bgcolor="#CCCCCC"

tdinput type="submit" value="登陆"/td

/tr

/table

/form

/center

/body

/html

2.checklogin.jsp登陆认证页面:

%@ page language="java" import="java.util.*" pageEncoding="GB2312"%

%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%

jsp:useBean id="Car" class="web.Car" scope="session"

jsp:setProperty property="*" name="Car"/

/jsp:useBean

%session.setMaxInactiveInterval(900); % %--设置session超时为30分--%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

base href="%=basePath%"

titleMy JSP 'checklogin.jsp' starting page/title

meta http-equiv="pragma" content="no-cache"

meta http-equiv="cache-control" content="no-cache"

meta http-equiv="expires" content="0"

meta http-equiv="keywords" content="keyword1,keyword2,keyword3"

meta http-equiv="description" content="This is my page"

!--

link rel="stylesheet" type="text/css" href="styles.css"

--

/head

body

%

String nextpage;

if(Car.getUserID().equals("Guest"))

nextpage="car.jsp";

else

nextpage="index.jsp";

%

jsp:forward page="%=nextpage%"/jsp:forward

/body

/html

3.car.jsp购物车页面

%@ page language="java" import="java.util.*" pageEncoding="GB2312"%

%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%

%@ page import="java.util.*" %

%@ page import="web.Car" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

base href="%=basePath%"

title购物车/title

meta http-equiv="pragma" content="no-cache"

meta http-equiv="cache-control" content="no-cache"

meta http-equiv="expires" content="0"

meta http-equiv="keywords" content="keyword1,keyword2,keyword3"

meta http-equiv="description" content="This is my page"

!--

link rel="stylesheet" type="text/css" href="styles.css"

--

/head

body

br%@ include file="header.jsp" %

hr

font size="2"

jsp:useBean id="Car" class="web.Car" scope="session"

/jsp:useBean

pfont color="#804040" face="楷体_GB2312"

strong百货商场,请尽情的选购商品添加到购物车!/strong

/font

%String str=response.encodeRedirectURL("add.jsp"); %

form action="%=str %" method="post" name="form"

select name="item" value="没选择"

option value="TV"电视机/option

option value="apple"苹果/option

option value="coke"可口可乐/option

option value="milk"牛奶/option

option value="tea"茶叶/option

/select

pfont color="#804040" face="楷体_GB2312"

输入购买的数量:

/font

input type="text" name="mount"

p

input type="radio" name="unit" value="个"个

input type="radio" name="unit" value="公斤"公斤

input type="radio" name="unit" value="台"台

input type="radio" name="unit" value="瓶"瓶p

input type="submit" value="提交添加"

/form

pfont color="#804040" face="楷体_GB2312"你的购物车里有如下商品:/font

font color="#FF8040" size="2"

%

Hashtable list=Car.list_h();

Enumeration enums=list.elements();

while(enums.hasMoreElements()){

String goods=(String) enums.nextElement();

byte b[]=goods.getBytes("ISO-8859-1");

goods=new String(b);

out.println("br"+goods);

}

%

/font

% String strl=response.encodeRedirectURL("selectRemoveGoods.jsp");%

form action="%=strl %" method="post" name="form"

input type="submit" value="修改购物车中的商品"

/form

/font

%@ include file="tail.jsp" %

/body

/html

4.add.jsp 增加物品:

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%

%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

base href="%=basePath%"

title购物车/title

meta http-equiv="pragma" content="no-cache"

meta http-equiv="cache-control" content="no-cache"

meta http-equiv="expires" content="0"

meta http-equiv="keywords" content="keyword1,keyword2,keyword3"

meta http-equiv="description" content="This is my page"

!--

link rel="stylesheet" type="text/css" href="styles.css"

--

/head

body

%@ include file="header.jsp" %

hr

font size="2"

jsp:useBean id="Car" class="web.Car" scope="session"/jsp:useBeanbr

jsp:setProperty name="Car" property="*"/

%Car.add_h();%

font face="楷体_GB2312"

font color="#FF8040" size="2"

p您的购物车有如下商品:

%

Hashtable list=Car.list_h();

Enumeration enums=list.elements();

while(enums.hasMoreElements()){

String goods=(String) enums.nextElement();

byte b[]=goods.getBytes("ISO-8859-1");

goods=new String(b);

out.println("br"+goods);

}

%

/font

%String str=response.encodeRedirectURL("car.jsp"); %

br

form action="%=str %" method="post" neme="form"

input type="submit" value="继续购物"

/form

%String strl=response.encodeRedirectURL("selectRemoveGoods.jsp"); %

br

form action="%=strl %" method="post" neme="form"

input type="submit" value="修改购物车中的物品"

/form

/font

/font

%@ include file="tail.jsp"%

/body

/html

5.selectRemoveGoods.jsp选择删除商品:

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%

%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%

%@ page import="java.util.*" %

%@ page import="web.Car" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

base href="%=basePath%"

title购物/title

meta http-equiv="pragma" content="no-cache"

meta http-equiv="cache-control" content="no-cache"

meta http-equiv="expires" content="0"

meta http-equiv="keywords" content="keyword1,keyword2,keyword3"

meta http-equiv="description" content="This is my page"

!--

link rel="stylesheet" type="text/css" href="styles.css"

--

/head

body

br%@ include file="header.jsp" %

hr

jsp:useBean id="Car" class="web.Car" scope="session"

/jsp:useBeanbr

p选择从购物车中删除的物品:

%String str=response.encodeRedirectURL("removeWork.jsp"); %

form action="%=str %" method="post" name="form"

select name="deleteitem" size="1"

option value="TV"电视机/option

option value="apple"苹果/option

option value="coke"可口可乐/option

option value="milk"牛奶/option

option value="tea"茶叶/option

/select

input type="submit" value="提交删除"

/form

font face="楷体_GB2312"

font color="#FF8040" size="2"

p您的购物车有如下商品:

%

Hashtable list=Car.list_h();

Enumeration enums=list.elements();

while(enums.hasMoreElements()){

String goods=(String) enums.nextElement();

byte b[]=goods.getBytes("ISO-8859-1");

goods=new String(b);

out.println("br"+goods);

}

%

/font/font

%String strl=response.encodeRedirectURL("car.jsp"); %

form action="%=strl %" method="post" neme="form"

input type="submit" value="继续购物"

/form

%@include file="tail.jsp" %

/body

/html

6.removeWork.jsp删除页面:

%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%

%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%

%@ page import="java.util.*" %

%@ page import="web.Car" %

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

base href="%=basePath%"

title购物车/title

meta http-equiv="pragma" content="no-cache"

meta http-equiv="cache-control" content="no-cache"

meta http-equiv="expires" content="0"

meta http-equiv="keywords" content="keyword1,keyword2,keyword3"

meta http-equiv="description" content="This is my page"

!--

link rel="stylesheet" type="text/css" href="styles.css"

--

/head

body

%@include file="header.jsp" %

hr

font size="2"

jsp:useBean id="Car" class="web.Car" scope="session"

/jsp:useBeanbr

%String str=response.encodeRedirectURL("removeWork.jsp"); %

%String name=request.getParameter("deleteitem");

if(name==null)

name="";

byte c[]=name.getBytes("ISO-8859-1");

name=new String(c);

Car.dele_h(name);

out.println("您删除了货物"+name);%

/font

font face="楷体_GB2312"

font color="#FF8040" size="2"

p您的购物车有如下商品:

%

Hashtable list=Car.list_h();

Enumeration enums=list.elements();

while(enums.hasMoreElements()){

String goods=(String) enums.nextElement();

byte b[]=goods.getBytes("ISO-8859-1");

goods=new String(b);

out.println("br"+goods);

}

%

/font/font

%String strp=response.encodeRedirectURL("car.jsp"); %

form action="%=strp %" method="post" neme="form"

input type="submit" value="继续购物"

/form

%String strl=response.encodeRedirectURL("selectRemoveGoods.jsp"); %

form action="%=strl %" method="post" neme="form"

input type="submit" value="修改购物车中的物品"

/form

/body

/html

7.header.jsp页面头部:

%@ page language="java" import="java.util.*" pageEncoding="GB2312"%

center

========================================================================br

购物车系统br

=======================================================================br

           

      WELCOME!

jsp:getProperty name="Car" property="userID"/

当前时间是:

%=new java.util.Date().toLocaleString() %

br

/center

8.tail页面尾部

%@ page language="java" import="java.util.*" pageEncoding="GB2312"%

center

hr

JSP+TOMCAT购物系统

/center

9.Car.java类

package web;

import java.util.*;

import java.io.*;

public class Car implements Serializable{

Hashtable list=new Hashtable(); //散列表,商品列表

String item="Welcome";

int mount=0; //商品数量

String unit=null; //商品单位

String userID; //用户

public void Car(){

}

public void setItem(String item) {

this.item = item;

}

public void setMount(int mount) {

this.mount = mount;

}

public void setUnit(String unit) {

this.unit = unit;

}

public String getUserID() {

return userID;

}

public void setUserID(String userID) {

this.userID = userID;

}

public Hashtable list_h() {

return list;

}

public void dele_h(String s) {

list.remove(s);

}

public void add_h(){

String str="Name:"+item+"Mount:"+mount+"Unit:"+unit;

list.put(item, str);

}

}

关于网上商城jsp代码和网上商城jsp代码大全的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/27926.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载