项目总结——Java web之实现当当网网站

Java web之实现当当网网站

运行环境:JDK1.8+tomcat8.4+MySQL5+servlet技术

源码结构

在这里插入图片描述
在这里插入图片描述

CategoryDAO.java

package com.tarena.dao;

import java.sql.SQLException;
import java.util.List;

import com.tarena.entity.Category;



public interface CategoryDAO {
	public List<Category> findAll() throws Exception;
	public List<Category> findByParentId(int pid) throws Exception;
}

DAOFactory.java

package com.tarena.dao;

import com.tarena.dao.impl.BookDAOImpl;
import com.tarena.dao.impl.CategoryDAOImpl;
import com.tarena.dao.impl.OrderDAOImpl;
import com.tarena.dao.impl.ReceiveAddressDAOImpl;
import com.tarena.dao.impl.UserDAOImpl;

public class DAOFactory {
	public static UserDAO getUserDAO() {
		return new UserDAOImpl();
	}

	public static CategoryDAO getCategoryDAO() {
		return new CategoryDAOImpl();
	}

	public static ProductDAO getProductDAO() {
		return new BookDAOImpl();
	}

	public static OrderDAO getOrderDAO() {
		return new OrderDAOImpl();
	}

	public static ReceiveAddressDAO getReceiveAddressDAO() {
		return new ReceiveAddressDAOImpl();
	}
}

OrderDAO.java

package com.tarena.dao;

import com.tarena.entity.Order;
import com.tarena.web.action.cart.CartService;



public interface OrderDAO {
	public void save(Order order,CartService cart) throws Exception;
}

ProductDAO.java

package com.tarena.dao;

import java.sql.SQLException;
import java.util.List;

import com.tarena.entity.Product;



public interface ProductDAO {
	public List<Product> findByCatId(int cid,int begin,int size) throws Exception;
	public Product findById(int id) throws Exception;


	public List<Product> findByHot(int num) throws Exception;
	

	public List<Product> findByNew(int num) throws Exception;
	
	
	public List<Product> findByNewHot(int num,long time) throws Exception;
}

ReceiveAddressDAO.java

package com.tarena.dao;

import java.util.List;

import com.tarena.entity.ReceiveAddress;

public interface ReceiveAddressDAO {

public void save(ReceiveAddress addr) throws Exception;

public List<ReceiveAddress> findByUserId(int userId) throws Exception;

public ReceiveAddress findById(int id) throws Exception;

}

main.jsp

<%@page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>当当图书 – 全球最大的中文网上书店</title>
		<link href="${pageContext.request.contextPath}/css/book.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/second.css" rel="stylesheet" type="text/css" />
		<link href="${pageContext.request.contextPath}/css/secBook_Show.css" rel="stylesheet" type="text/css" />
	
	</head>
	<body>&nbsp; 
		<!-- 头部开始 -->
		<%@include file="/common/head.jsp"%>
		<!-- 头部结束 -->
		<div style="width: 962px; margin: auto;">
			<a href="#" target="_blank"><img
					src="${pageContext.request.contextPath}/images/default/book_banner_081203.jpg" border="0" /> </a>
		</div>

		<div class="book">

			<!--左栏开始-->
			<div id="left" class="book_left">
				<s:action name="categoryAction" namespace="/main" executeResult="true"></s:action>
			</div>
			<!--左栏结束-->

			<!--中栏开始-->
			<div class="book_center">

				<!--推荐图书开始-->
				<div class=second_c_border1 id="recommend">
					<s:action name="recommendAction" namespace="/main" executeResult="true"></s:action>
				</div>

				<!--推荐图书结束-->

				<!--热销图书开始-->
				<div class="book_c_border2" id="hot">
					<s:action name="hotAction" namespace="/main" executeResult="true"></s:action>
				</div>
				<!--热销图书结束-->

				<!--最新上架图书开始-->
				<div class="book_c_border2" id="new">
					<s:action name="newAction" namespace="/main" executeResult="true"></s:action>
				</div>

				<!--最新上架图书结束-->

				<div class="clear">
				</div>
			</div>
			<!--中栏结束-->



			<!--右栏开始-->
			<div class="book_right">
				<div class="book_r_border2" id="__XinShuReMai">
					<div class="book_r_b2_1x" id="new_bang">
						<h2 class="t_xsrm">
							新书热卖榜
						</h2>
						<div id="NewProduct_1_o_t" onmouseover="">
							<s:action name="newHotAction" namespace="/main" executeResult="true"></s:action>
							<h3 class="second">
								<span class="dot_r"> </span><a href="#" target="_blank">更多&gt;&gt;</a>
							</h3>
						</div>
					</div>
				</div>
			</div>
			<!--右栏结束-->
			<div class="clear"></div>
		</div>

		<!--页尾开始 -->
		<%@include file="/common/foot.jsp"%>
		<!--页尾结束 -->
	</body>
</html>

## 有任何疑问和和源码需求敬请关注公众号【蜗牛资源社】

欢迎交流学习!

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值