环境
数据库: Oracle XE
数据库连接软件: Navicat
Java: JDK1.8.0_171
IDE: Eclipse Photon June 2018
Servers: Tomcat 8.0.53
数据建模
Book {id, name, price, type}
Customer [name, passwd, zip, address, telephone, email]
OrederFrom [id, cost, orderDate, customer, shipadress]
OrderLine [id, num, orderForm, book]
ShipAddress [id, shipuName, adres, phone, customer]
数据库连接
1 | package xyz.ffshine.common; |
注册
service
1 | package xyz.ffshine.service.impl; |
servlet
1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
登陆
servlet
1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
把数据库中的Book 传入首页
listener
1 | public void sessionCreated(HttpSessionEvent hse) { |
bookService
1 | package xyz.ffshine.service.impl; |
在页面展示穿入的Book
1 | <c:forEach items="${sessionScope.books}" var="book"> |
其中
1 | <a href="viewBook.jsp?name=${book.name}&price=${book.price}&cus_id=${customer.id}&book_id=${book.id}"> |
把本书的信息传入ViewBook页面
ViewBook
数据获取
1 | <% |
数据展示
1 | <div id="demo" class="cn5topy_1"> |
其中属性为”display: none” 的标签是为了更好地用js构建向下一页的跳转链接
跳转链接构建
1 | function addShopCart(){ |
购物车
加入购物车
1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
购物车展示
1 | <c:forEach items="${sessionScope.orLines}" var="orLine"> |
用jQuery 实现购物车增与减 全选与取消全选(删除还未实现)
1 | //+ 的功能 |
构建跳转链接
1 | function jump() { |
bookId, bookNum 拼装成一个String 中间用a隔开 在servlet 中再解开
显示订单(待结算界面)
servlet
1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
将购物车传入的数据写入数据库 并取出所有相关数据(数据库已存在地址,订单) 传出页面
结算页面展示订单信息
1 | <c:forEach items="${sessionScope.orderLines}" var="order"> |
展示地址
1 | <c:forEach items="${sessionScope.addrs}" var="addr"> |
选择地址
1 | function addShipaddress(name,address,phone,id){ |
添加地址
1 | //确认新增收货地址 |
AddShipaddressServlet
1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
跳转
1 | function confirmOrder(cus_id, cost, or_id) { |
##订单详情
ConfirmSucServlet
根据 cus_id 和 sid 获得相关订单和地址
1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
在页面展示
1 | <span style="font-size:15px;color: red"> |
我的订单
根据已有信息展示
1 | <tr> |
判断数据库中订单是否为已结算订单
判断是否有总价 有的话显示 否则不显示
1 |
|