首页上的热门商品和最新商品

首页上的热门商品和最新商品

步骤分析:
    页面加载的时候 查询最新商品 和 热门商品即可
    在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">&yen;${p.shop_price }</font>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值