日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
網(wǎng)上購物商城java代碼 電商購物平臺java代碼

用java寫一個手機商城注冊界面代碼

這篇文章主要介紹了java通過JFrame做一個登錄系統(tǒng)的界面完整代碼示例,具有一定借鑒價值,需要的朋友可以參考下。

成都創(chuàng)新互聯(lián)公司專業(yè)提供成都主機托管四川主機托管成都服務器托管四川服務器托管,支持按月付款!我們的承諾:貴族品質(zhì)、平民價格,機房位于中國電信/網(wǎng)通/移動機房,鄭州服務器托管服務有保障!

在java的JFrame內(nèi)通過創(chuàng)建匿名對象的方式做登錄界面

package com.sxt;

import java.awt.Container;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class LoginFrame extends JFrame{

JTextField txtname=new JTextField();

JPasswordField txtpass=new JPasswordField();

JButton bl=new JButton("登錄");

JButton bg=new JButton("關閉");

//構(gòu)造無參構(gòu)造器把主要的方法放在構(gòu)造器里,然后在main方法里面調(diào)

public LoginFrame(){

setBounds(25,25,250,250);

Container c = getContentPane();

c.setLayout(new GridLayout(4,2,10,10));

c.add(new JLabel("用戶名"));

c.add(txtname);

c.add(new JLabel("密碼"));

c.add(txtpass);

c.add(bl);

c.add(bg);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setVisible(true);

//注意:此處是匿名內(nèi)部類

bg.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

System.exit(0);

}

}

);

//注意:此處是匿名內(nèi)部類

bl.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

數(shù)據(jù)庫如何用java寫超市購物程序?

要使用Java編寫超市購物程序,您需要使用Java數(shù)據(jù)庫編程技術來連接到您的數(shù)據(jù)庫并執(zhí)行相關的數(shù)據(jù)庫操作。在Java中,您可以使用JDBC(Java數(shù)據(jù)庫連接)API來連接到數(shù)據(jù)庫并執(zhí)行SQL語句。例如,您可以使用JDBC API來執(zhí)行以下操作:

創(chuàng)建數(shù)據(jù)庫連接

執(zhí)行增刪改查(CRUD)操作

提交或回滾事務

執(zhí)行存儲過程和函數(shù)

查詢數(shù)據(jù)庫元數(shù)據(jù)

此外,您還可以使用Java的面向?qū)ο缶幊碳夹g來封裝數(shù)據(jù)庫操作,以便更方便地在您的程序中使用。例如,您可以創(chuàng)建一個類來表示超市商品,并定義一些方法來執(zhí)行商品的增刪改查操作。這樣,您就可以在程序中通過調(diào)用這些方法來簡單地完成對數(shù)據(jù)庫的操作,而不需要編寫復雜的SQL語句。

用java編程實現(xiàn)網(wǎng)上超市購物結(jié)算功能代碼

哎,我還是自己代碼黏貼給你吧!免得總通不過!裝不下這么多字,詳情自己找我。 連接數(shù)據(jù)庫類(添加修改會員信息) package com.to.java; import java.util.Scanner; import java.sql.*; public class Vds { Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); public void x(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); System.out.println("----------查詢結(jié)果---------"); System.out.println(); System.out.println("會員號--密碼"); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } con.close(); stmt.close(); }catch(Exception e){ System.out.println(e);} System.out.println("是否返回上級菜單"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("歡迎下次再次使用");System.exit(-1);}; break; }} public void j(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("請輸入會員信息:"); System.out.println("請輸入會員號:"); String f=input.next(); System.out.println("請輸入密碼:"); String q=input.next(); String sqlst="insert into gg values('"+f+"','"+q+"')"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上級菜單"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("歡迎下次再次使用");System.exit(-1);}; break; } } public void xg(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("請輸入會員信息:"); System.out.println("請輸入要修改的會員號:"); String f=input.next(); System.out.println("請輸入修改的密碼:"); String q=input.next(); String sqlst="update gg set mm='"+q+"' where id='"+f+"'"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上級菜單"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("歡迎下次再次使用");System.exit(-1);}; break; } } } package com.to.java; import java.util.Scanner; public class KeHu { Vds sj=new Vds(); public void kehu1(){ Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("******************************************************"+"\n\n"); System.out.println("1.顯示所有客戶信息"); System.out.println("2.添加客戶信息"); System.out.println("3.修改客戶信息"); System.out.println("4.查詢客戶信息"); System.out.println("5.返回上級菜單"); System.out.println("******************************************************"+"\n\n"); System.out.println("請輸入數(shù)字:"); int a=Input.nextInt(); switch(a){ case 1: sj.x(); break; case 2: sj.j(); break; case 3: sj.xg(); break; case 4: sj.x();break; case 5: zhuck1.ZhucK1();break; } } } package com.to.java; public class GouWuXiTong { public static void main(String[] args){ ZhuCK zhuck=new ZhuCK(); zhuck.ZhucK(); } } package com.to.java; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Scanner; public class ZhuCK { Scanner Input=new Scanner(System.in); public void ZhucK(){ ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("\t\t"+"歡迎使用我心我素購物系統(tǒng)"); System.out.println("******************************************************"+"\n\n"); System.out.println("\t\t"+"1.登陸系統(tǒng)"); System.out.println(); System.out.println("\t\t"+"2.退出"+"\n\n"); System.out.println("******************************************************"); int d=1; while(d!=2){ System.out.println("請輸入會員號:"); String p=Input.next(); System.out.println("請輸入密碼:"); String f=Input.next(); try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select * from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); if(id.equals(p)mm.equals(f)){ { System.out.println("請輸入數(shù)字:"); int a=Input.nextInt(); switch(a){ case 1: zhuck1.ZhucK1(); break; case 2: break; }d=2; } } } }catch(Exception e){ System.out.println(e);} {System.out.println("輸入錯誤請再次輸入:");d=1;} } }} }

jsp網(wǎng)上購物代碼及操作!

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"

輸入購買的數(shù)量:

/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="繼續(xù)購物"

/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="繼續(xù)購物"

/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="繼續(xù)購物"

/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

購物車系統(tǒng)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購物系統(tǒng)

/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; //商品數(shù)量

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,java代碼怎么寫,有父類子類的?

N種辦法

1、mybatis 配置文件 寫SQL 解決

2、通過JAVA service 通過父類信息查詢子類并封裝

3、提供一個接口,前臺二級聯(lián)動方式,點第一個給后臺傳值0 ,查詢父ID為0 的 當點擊第二個聯(lián)動的時候 把第一個信息的ID 給你傳過去,如 電子數(shù)碼ID 為1 那就傳1 后臺還是根據(jù)父類查詢,也就是 父類ID 1 這樣就查出 所對應的 子類信息了。


本文標題:網(wǎng)上購物商城java代碼 電商購物平臺java代碼
轉(zhuǎn)載注明:http://www.dlmjj.cn/article/docipdh.html