CShop Project 08: 开发条幅商品在首页的展示
作者:互联网
1. GoodsDao.java
public Map<String, Object> getScrollGoods() throws SQLException { QueryRunner r = new QueryRunner(DBUtil.getDataSource()); String sql = "select g.id,g.name,g.cover,g.price from recommend r,goods g where type=1 and r.goods_id=g.id "; return r.query(sql,new MapHandler()); }
2. GoodsService.java
public Map<String, Object> getScrollGoods(){ Map<String, Object> map = null; try { map = gDao.getScrollGoods(); } catch (SQLException e) { e.printStackTrace(); } return map; }
3. IndexServlet.java
doGet(){ // 取得条幅商品 Map<String,Object> scrollGoods = gService.getScrollGoods(); request.setAttribute("scroll", scrollGoods); }
4. index.jsp
<!--banner--> <div class="banner"> <div class="container"> <h2 class="hdng"><a href="detail.action?goodid=7">${scroll.name }</a><span></span></h2> <p>今日精选推荐</p> <a class="banner_a" href="javascript:;" onclick="buy(7)">立刻购买</a> <div class="banner-text"> <a href="detail.action?goodid=7"> <img src="${pageContext.request.contextPath }${scroll.cover}" alt="${scroll.name }" width="350" height="350"> </a> </div> </div> </div> <!--//banner-->
效果:
标签:Map,CShop,java,map,08,scrollGoods,Project,getScrollGoods,id 来源: https://www.cnblogs.com/JasperZhao/p/13551679.html