首页上的热门商品和最新商品
步骤分析:
页面加载的时候 查询最新商品 和 热门商品即可
在indexServlet的index方法中实现就可以了
查询的结果两个list,将两个list放入request域中,请求转发到index.jsp即可
在index.jsp中展示
准备工作:
数据库和表
CREATE TABLE `product` (
`pid` varchar(32) NOT NULL,
`pname` varchar(50) DEFAULT NULL,
`market_price` double DEFAULT NULL,
`shop_price` double DEFAULT NULL,
`pimage` varchar(200) DEFAULT NULL,
`pdate` date DEFAULT NULL,
`is_hot` int(11) DEFAULT NULL,
`pdesc` varchar(255) DEFAULT NULL,
`pflag` int(11) DEFAULT NULL,
`cid` varchar(32) DEFAULT NULL,
PRIMARY KEY (`pid`),
KEY `sfk_0001` (`cid`),
CONSTRAINT `sfk_0001` FOREIGN KEY (`cid`) REFERENCES `category` (`cid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2、插入数据
javabean product
ProductService ProductDao
----------------------------------------------------------------------------------------------------
热门商品前台
<c:forEach items="${hList }" var="p">
<div class="col-md-2"
style="text-align: center; height: 200px; padding: 10px 0px;">
<a href="${pageContext.request.contextPath }/product?method=getByPid&pid=${p.pid}"> <img
src="${pageContext.request.contextPath}/${p.pimage}" width="130"
height="130" style="display: inline-block;">
</a>
<p>
<a href="${pageContext.request.contextPath }/product?method=getByPid&pid=${p.pid}" style='color: #666'>${fn:substring(p.pname,0,10)}... </a>
</p>
<p>
<font color="#E4393C" style="font-size: 16px">¥${p.shop_price }</font>