1. 哪個朋友有基於Javaweb的簡單的購物網站 要求能有購物車付款,登陸 注冊。能夠在頁面搜索商品,是簡單的
這有個圖書商城 和你說的一樣 要就see my name 濂溪哦
2. Java GUI 如何解決類似於購物車跟隨子界面
iframe彈出層建議使用第三方介入的jar包進行開發。【layer彈窗】差不多就可以實現你說的這種效果!!!
3. java簡單的購物車代碼
packageTest;
importjava.util.LinkedHashMap;
importjava.util.Map;
importjava.util.Map.Entry;
importjava.util.Scanner;
publicclassTest{
publicstaticvoidmain(String[]args){
init();//初始化
Map<String,String>map=newLinkedHashMap<>();
while(true){
Scannerin=newScanner(System.in);
map=buy(in,map);//選擇
System.out.println();
System.out.println("還要繼續購物嗎?(Y/N)");
Stringjx=in.nextLine();
if(jx.equals("N")){
break;
}
}
print(map);
}
publicstaticvoidprint(Map<String,String>m){
System.out.println("
******************");
System.out.println("購物車清單");
Integerhj=0;
for(Entry<String,String>entry:m.entrySet()){
Stringkey=entry.getKey();
Stringvalue=entry.getValue();
if(key.equals("1")){
hj+=Integer.parseInt(value)*3;
System.out.println("哇哈哈純凈水:"+value+"件,合計:¥"+Integer.parseInt(value)*3);
}elseif(key.equals("2")){
hj+=Integer.parseInt(value)*5;
System.out.println("康師傅方便麵:"+value+"件,合計:¥"+Integer.parseInt(value)*5);
}elseif(key.equals("3")){
hj+=Integer.parseInt(value)*4;
System.out.println("可口可樂:"+value+"件,合計:¥"+Integer.parseInt(value)*4);
}
}
System.out.println("合計金額:¥"+hj);
}
publicstaticvoidinit(){
System.out.println("******************");
System.out.println(" 商品列表
");
System.out.println("商品名稱價格");
System.out.println("1.哇哈哈純凈水¥3");
System.out.println("2.康師傅方便麵¥5");
System.out.println("3.可口可樂¥4");
System.out.println("******************");
}
publicstaticMap<String,String>buy(Scannerscan,Map<String,String>m){
System.out.print("請輸入編號:");
Stringbh=scan.nextLine();
System.out.print("請輸入購買數量:");
Stringnum=scan.nextLine();
if(m.size()>0&&m.keySet().contains(bh)){
m.put(bh,(Integer.parseInt(bh)+Integer.parseInt(num))+"");
}else{
m.put(bh,num);
}
returnm;
}
}
4. 用java設計一個簡單的界面設計,越簡單越好,謝謝
用java設計一個簡單的界面可以參考如下實例:
importjavax.swing.JFrame;//框架
importjavax.swing.JPanel;//面板
importjavax.swing.JButton;//按鈕
importjavax.swing.JLabel;//標簽
importjavax.swing.JTextField;//文本框
importjava.awt.Font;//字體
importjava.awt.Color;//顏色
importjavax.swing.JPasswordField;//密碼框
importjava.awt.event.ActionListener;//事件監聽
importjava.awt.event.ActionEvent;//事件處理
importjavax.swing.JOptionPane;//消息窗口{
publicJPanelpnluser;
publicJLabellbluserLogIn;
publicJLabellbluserName;
publicJLabellbluserPWD;
publicJTextFieldtxtName;
publicJPasswordFieldpwdPwd;
publicJButtonbtnSub;
publicJButtonbtnReset;
publicUserLogIn(){
pnluser=newJPanel();
lbluserLogIn=newJLabel();
lbluserName=newJLabel();
lbluserPWD=newJLabel();
txtName=newJTextField();
pwdPwd=newJPasswordField();
btnSub=newJButton();
btnReset=newJButton();
userInit();
}
publicvoiserInit(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設置關閉框架的同時結束程序
this.setSize(300,200);//設置框架大小為長300,寬200
this.setResizable(false);//設置框架不可以改變大小
this.setTitle("用戶登錄");//設置框架標題
this.pnluser.setLayout(null);//設置面板布局管理
this.pnluser.setBackground(Color.cyan);//設置面板背景顏色
this.lbluserLogIn.setText("用戶登錄");//設置標簽標題
this.lbluserLogIn.setFont(newFont("宋體",Font.BOLD|Font.ITALIC,14));//設置標簽字體
this.lbluserLogIn.setForeground(Color.RED);//設置標簽字體顏色
this.lbluserName.setText("用戶名:");
this.lbluserPWD.setText("密碼:");
this.btnSub.setText("登錄");
this.btnReset.setText("重置");
this.lbluserLogIn.setBounds(120,15,60,20);//設置標簽x坐標120,y坐標15,長60,寬20
this.lbluserName.setBounds(50,55,60,20);
this.lbluserPWD.setBounds(50,85,60,25);
this.txtName.setBounds(110,55,120,20);
this.pwdPwd.setBounds(110,85,120,20);
this.btnSub.setBounds(85,120,60,20);
this.btnSub.addActionListener(newActionListener()//匿名類實現ActionListener介面
{
publicvoidactionPerformed(ActionEvente){
btnsub_ActionEvent(e);
}
}
);
this.btnReset.setBounds(155,120,60,20);
this.btnReset.addActionListener(newActionListener()//匿名類實現ActionListener介面
{
publicvoidactionPerformed(ActionEvente){
btnreset_ActionEvent(e);
}
}
);
this.pnluser.add(lbluserLogIn);//載入標簽到面板
this.pnluser.add(lbluserName);
this.pnluser.add(lbluserPWD);
this.pnluser.add(txtName);
this.pnluser.add(pwdPwd);
this.pnluser.add(btnSub);
this.pnluser.add(btnReset);
this.add(pnluser);//載入面板到框架
this.setVisible(true);//設置框架可顯
}
publicvoidbtnsub_ActionEvent(ActionEvente){
Stringname=txtName.getText();
Stringpwd=String.valueOf(pwdPwd.getPassword());
if(name.equals("")){
JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}elseif(pwd.equals("")){
JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}elseif(true){
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}
}
publicvoidbtnreset_ActionEvent(ActionEvente){
txtName.setText("");
pwdPwd.setText("");
}
publicstaticvoidmain(String[]args){
newUserLogIn();
}
}
5. 跪求一個簡單的Jsp購物網站,有購物車,商品展示,登錄界面,管理員界面,後台管理,連接SQL,還有Javabean
分給我,我傳你!
6. 想做一個簡單的購物車界面,非常簡單就行有代碼!用div+css做就可以
購物車外是可以的 但是核心最好還是用程序本來的核心如果自己寫,很有單獨
7. 各位java web大神,求幫忙看個超小的demo,實現一個簡單的購物車功能,出現了很讓人費解的問題,不看後悔
我運行了你的代碼獲取到的是同一個session啊,沒問題啊
8. 怎麼用java代碼來實現jsp網頁里的購物車里的模塊
購物車都是存在cookie里的,一般不登陸都是可以加入購物車的。加入購物車就寫到cookie里就ok了。
9. java web 做購物車的大概思路,和實現步奏是什麼
購物車管理模塊主要功能有如下幾個部分:(1)創建購物車 當客戶登錄後,系統會給客戶創建一個購物車放入伺服器的Session會話中。使客戶在整個會話中都擁有一個相同的購物車。這里主要運用了Http協議中的會話機制,將購物車保存在客戶的會話中,這樣在整個客戶游覽不同頁面商品的過程中,都會使用同一個購物車對象。 具體執行步驟:(1)從客戶的請求對象中獲取Session會話對象(2)從會話對象中獲取購物車對象(3)判斷是購物車對象是不是空的,如果是空是就創建一個 /* * 在監聽到session被創建之後,就立即向session中添加一個購物車Car; */ public void sessionCreated(HttpSessionEvent arg0) { HttpSession session = arg0.getSession(); Cart cart=new Cart(); session.setAttribute("cart", cart); } /* * 從session中獲得購物車 */ Cart cart = (Cart) session.getAttribute("cart"); if (cart == null) { cart = new Cart(); }(2)向購物車中添加一個商品項 客戶在查看網頁上的一個商品時,當向伺服器發送一個「添加到購物車」的請求時,會執行這個功能。功能執行過程:(1)從客戶請求對象中獲取商品的ID(2)調用業務層的方法根據商品ID去數據查詢商品的信息,返回商品對象(3)從商品對象中獲取商品名,商品價格,來構建一個商品項對象(4)從Session會話中獲取購物車對象(5)調用業務層的方法來根據購物車對象和商品項對象來執行添加操作(6)將些商品項對象放入到購物車中 部分實現代碼: /* * 從資料庫中把商品取到; */ ProctService proctService = (ProctService) ServiceFactory.getInstance().getService(Globals.PRODUCT_SERVICE); Integer id = Integer.parseInt(request.getParameter("proctid")); Proct proct = proctService.getProctById(id); /* * 在向購物車中添加商品的時候會判斷商品是否已經存在, * 已存在的就不讓在加入了; */ if (cart.isExist(id)) { message = "該商品已經存在!請<a onclick='javascript:history.go(-1)'>返回</a>!"; request.setAttribute("message", message); return mapping.findForward("error"); } else { /* * 向購物車添加一個商品; */ cart.addCart(proct); session.setAttribute("cart", cart); return mapping.findForward("addcartsuccess"); }
10. 求J2EE做一個簡單的購物車系統 servlet+javabean+html的最好,謝謝!
老兄,既然簡單,何不自己動手呢,豈不更有感覺。知道原理,這功能做起來不難。要內html是做什麼用,動態語言里容面,他只能做靜態頁面。寫一些js,提交表單,僅此而以,後台的值它一樣都獲取不了。
購物車,說白了就是伺服器內存裡面的一個對象,然後到客戶端去顯示。當然也可以永遠的保存到資料庫,這里就不說了。它可以是List,也可以是Set,可以put(商品),也可以remove(商品),還可以clear(商品),對象存放於session,隨時可以取用