Java?web實(shí)現(xiàn)購物車案例
本文實(shí)例為大家分享了Java web實(shí)現(xiàn)購物車的具體實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
一. 簡介:
本項(xiàng)目使用jsp,js,Java,html,css,EL表達(dá)式,JSTL所實(shí)現(xiàn)
使用編輯器:idea
使用Oracle數(shù)據(jù)庫
新增:
EL表達(dá)式
JSTL標(biāo)簽庫
二. 前臺
1.包括用戶注冊,登錄
Html +js+jsp
效果展示
<body> <div class="jq22-container" style="padding-top:100px"> ? ? <div class="login-wrap"> ? ? ? ? <div class="login-html"> ? ? ? ? ? ? <input id="tab-1" type="radio" name="tab" class="sign-in" checked><label for="tab-1" class="tab">登錄</label> ? ? ? ? ? ? <input id="tab-2" type="radio" name="tab" class="sign-up"><label for="tab-2" class="tab">注冊</label> ? ? ? ? ? ? <div class="login-form"> ? ? ? ? ? ? ? ? <div class="sign-in-htm"> ? ? ? ? ? ? ? ? ? ? <form action="${pageContext.request.contextPath }/LoginServlet.do" method="post" onsubmit="return checkAll()"> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="user1" class="label">賬號</label> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input name="uname" id="uname" type="text" class="input"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="upwd" class="label">密碼</label> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input name="upwd" id="upwd" type="password" class="input" data-type="password"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input id="check" type="checkbox" class="check"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="check"><span class="icon"></span>自動登錄</label> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input type="submit" class="button" value="登錄"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? </form> ? ? ? ? ? ? ? ? ? ? <div class="hr"></div> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? <div class="sign-up-htm"> ? ? ? ? ? ? ? ? ? ? <form action="${pageContext.request.contextPath }/registerServlet.do" method="post"> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="user1" class="label">賬號</label> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input id="user1" type="text" class="input"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="upwd" class="label">密碼</label> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input id="upwd1" type="password" class="input" data-type="password"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="pass3" class="label">確認(rèn)密碼</label> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input id="pass3" type="password" class="input" data-type="password"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="group"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input type="submit" class="button" value="注冊"> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="hr"></div> ? ? ? ? ? ? ? ? ? ? ? ? <div class="foot-lnk"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <label for="tab-1"></label> ? ? ? ? ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? ? ? </form> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? </div> ? ? ? ? </div> ? ? </div> </div> </body>
2.主界面(效果圖);
使用了List集合保存數(shù)據(jù)并綁定頁面
<body> <div class="container"> ? ? <h3 style="text-align: center">商城列表</h3> ? ? ? ? ? ? <form> ? ? ? ? ? ? ? ? <table border="1" class="table table-bordered table-hover"> ? ? ? ? ? ? ? ? ? ? <tr class="success"> ? ? ? ? ? ? ? ? ? ? ? ? <th>商品序號</th> ? ? ? ? ? ? ? ? ? ? ? ? <th>商品名稱</th> ? ? ? ? ? ? ? ? ? ? ? ? <th>商品價(jià)格</th> ? ? ? ? ? ? ? ? ? ? ? ? <th>商品描述</th> ? ? ? ? ? ? ? ? ? ? ? ? <th>商品圖片</th> ? ? ? ? ? ? ? ? ? ? ? ? <th>操作</th> ? ? ? ? ? ? ? ? ? ? </tr> ? ? ? ? ? ? ? ? ? ? <c:forEach var="good" items="goods"> ? ? ? ? ? ? ? ? ? ? ? ? <tr> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>${good.gid()}</td> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>${good.gname()}</td> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>${good.gprice()}</td> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>${good.ginfo()}</td> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td><img src="../static/${good.gpath()}"></td> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td><a class="btn btn-default btn-sm" href="${pageContext.request.contextPath }/goodsServlet.do?nid=${good.gid()}" >購買</a> </td> ? ? ? ? ? ? ? ? ? ? ? ? </tr> ? ? ? ? ? ? ? ? ? ? </c:forEach> ? ? ? ? ? ? ? ? </table> ? ? ? ? ? ? </form> </div> </body>
3.購物車(效果圖):
使用了session保存數(shù)據(jù)從主界面?zhèn)鲄?shù)
這是jsp代碼,里面加入了EL表達(dá)式和jstl
<body> <div class="container"> ? ? <h3 style="text-align: center">購物車列表</h3> ? ? <table border="1" class="table table-bordered table-hover"> ? ? ? ? <tr class="success"> ? ? ? ? ? ? <th><input type="checkbox" id="chElt" onclick="checkOrCancelAll()"><span id="mySpan"></span></th> ? ? ? ? ? ? <th>商品序號</th> ? ? ? ? ? ? <th>商品名稱</th> ? ? ? ? ? ? <th>商品描述</th> ? ? ? ? ? ? <th>商品圖片</th> ? ? ? ? ? ? <th>商品數(shù)量</th> ? ? ? ? ? ? <th>商品總價(jià)</th> ? ? ? ? ? ? <th>操作</th> ? ? ? ? </tr> ? ? ? ? <c:forEach var="s" items="listshopping"> ? ? ? ? ? ? <tr> ? ? ? ? ? ? ? ? <td><input type="checkbox" class="interest"></td> ? ? ? ? ? ? ? ? <td>${s.Sid()}</td> ? ? ? ? ? ? ? ? <td>${s.Sname()}</td> ? ? ? ? ? ? ? ? <td>${s.Sinfo()}</td> ? ? ? ? ? ? ? ? <td><img src="../static/${s.Spath()}"></td> ? ? ? ? ? ? ? ? <input id="${s.Sid()}" style="width: 40px;text-align: center;" type="text" value="${s.Count()}"/> ? ? ? ? ? ? ? ? <td>總價(jià)錢</td> ? ? ? ? ? ? ? ? <td> ? ? ? ? ? ? ? ? ? ? <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath }/goodsServlet.do" >購買</a>  ? ? ? ? ? ? ? ? ? ? <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath }/shoppingServlet.do?nid=${s.Sid()}" >刪除</a> ? ? ? ? ? ? ? ? ? ? <a class="btn btn-default btn-sm" href="/updateOrder.do?nid=${s.Sid()}" >修改</a> ? ? ? ? ? ? ? ? </td> ? ? ? ? ? ? </tr> ? ? ? ? ? ? <tr> ? ? ? ? ? ? ? ? <td colspan="8" align="left"><a href="${pageContext.request.contextPath }/admin/xmb.jsp" >返回商品頁面</a></td> ? ? ? ? ? ? ? ? <td colspan="8" align="right"><a href="${pageContext.request.contextPath }/closeServlet.do?nid=${s.Sid()}" >我要結(jié)賬</a></td> ? ? ? ? ? ? </tr> ? ? ? ? </c:forEach> ? ? </table> </div> </body>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- JavaWeb購物車項(xiàng)目開發(fā)實(shí)戰(zhàn)指南
- JavaWeb后臺購物車類實(shí)現(xiàn)代碼詳解
- eclipse的web項(xiàng)目實(shí)現(xiàn)Javaweb購物車的方法
- javaweb購物車案列學(xué)習(xí)開發(fā)
- java web開發(fā)之購物車功能實(shí)現(xiàn)示例代碼
- javaweb圖書商城設(shè)計(jì)之購物車模塊(3)
- java web開發(fā)之實(shí)現(xiàn)購物車功能
- java商城項(xiàng)目實(shí)戰(zhàn)之購物車功能實(shí)現(xiàn)
- JAVAEE中用Session簡單實(shí)現(xiàn)購物車功能示例代碼
- java實(shí)現(xiàn)網(wǎng)上購物車程序
相關(guān)文章
Java實(shí)現(xiàn)的質(zhì)因數(shù)分解操作示例【基于遞歸算法】
這篇文章主要介紹了Java實(shí)現(xiàn)的質(zhì)因數(shù)分解操作,結(jié)合實(shí)例形式較為詳細(xì)的分析了Java基于遞歸算法實(shí)現(xiàn)針對整數(shù)的質(zhì)因數(shù)分解相關(guān)操作技巧,需要的朋友可以參考下2018-03-03startJVM錯(cuò)誤Unable to load native library: libjvm.so解決方法
這篇文章主要介紹了startJVM錯(cuò)誤Unable to load native library: libjvm.so解決方法,需要的朋友可以參考下2014-07-07MybatisPlus 多租戶架構(gòu)(Multi-tenancy)實(shí)現(xiàn)詳解
這篇文章主要介紹了MybatisPlus 多租戶架構(gòu)(Multi-tenancy)實(shí)現(xiàn)詳解,詳細(xì)的介紹了什么是多租戶架構(gòu)以及使用MybatisPlus實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-11-11java并發(fā)學(xué)習(xí)之Executor源碼解析
這篇文章主要為大家介紹了java并發(fā)學(xué)習(xí)之Executor源碼示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07SpringBoot中實(shí)現(xiàn)訂單30分鐘自動取消的項(xiàng)目實(shí)踐
現(xiàn)在電子商務(wù)平臺上訂單創(chuàng)建成功,等待支付,一般會給30分鐘的時(shí)間,本文主要介紹了SpringBoot中實(shí)現(xiàn)訂單30分鐘自動取消的項(xiàng)目實(shí)踐,具有一定的參考價(jià)值,感興趣的可以了解一下2023-10-10springboot接入cachecloud redis示例實(shí)踐
這篇文章主要介紹了springboot接入cachecloud redis示例實(shí)踐,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10