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

购物订单提交页面代码(购物界面代码)

admin 发布:2022-12-19 20:47 119


今天给各位分享购物订单提交页面代码的知识,其中也会对购物界面代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

JSP 查看订单所有信息页面的代码

jsp里面嵌套java代码这种方式不可取啊。更甚是在页面连接数据库。

编程需要严谨处之。。

不知lz要实现什么样的功能【效果】。

但是其实每一个功能的实现都是源于有什么需求的,一步步抽丝剥茧的挖掘。需要什么就创造什么,就可以逐步实现这个功能了。

譬如说【根据过来的名字去数据库查找相应的订单,在前台可以查看自己的订单】

获得输入名字,发送请求到服务器,经由业务层 层层转发到数据访问层,根据名字来取得一个对应对象层层返回即可。

求ASP.NET和C#方面的大神帮忙写购物车和订单提交的代码

提交订单就是最简单的insert。购物车麻烦一点,可以用cookie实现,也可以用数据库,现在大部分网站都是数据库的了,可以永久保存。

很多网站下面都有提交订单,请高手指点怎么设置?如何添加到网站?谢谢!【范例如下图】

这个是利用HTML中的表单功能,在此以图中为例示范一个代码:

!--表单文件名假如为:order.html--

div class="order_form"

   form name="postOrder" method="post" action=""

     p订单提交/p

        *产品套餐:input type="text" name="taocan" value="" /

      *订购人姓名:input type="text" name="name" value="" /

        *收货地址:input type="text" name="address" value="" /

            *手机:input type="text" name="phone" value="" /

         付款方式:input type="radio" name="payment_style" value="货到付款" /  input type="radio" name="payment_style" value="验货满意后再付款" /

         留言:textarea name="message" /textarea

         input type="submit" name="submit1" value="我填好了,立即提交订单" /     

   /form

/div

!--说明:其中action=""是用来放处理这个表单提交的动态程序的地址的,具体用什么语言写要看你用什么数据库和服务器了。--

【打字不容易,记得给分!】

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);

}

}

购物订单提交页面代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于购物界面代码、购物订单提交页面代码的信息别忘了在本站进行查找喔。

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

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


取消回复欢迎 发表评论:

分享到

温馨提示

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

联系我们反馈

立即下载