首页 > 代码库 > 后台数据库取值 轮播图

后台数据库取值 轮播图

<div>
    <div id="myCarousel" class="carousel slide">
        <!-- 轮播(Carousel)指标 -->
        <ol class="carousel-indicators" style="bottom: 0;">
            <c:forEach items="${advertList}" var="advert" varStatus="advert1">
                <c:if test="${advert1.index == 0}">
                    <li data-target="#myCarousel" data-slide-to="${advert1.index}" class="active"></li>
                </c:if>
                <c:if test="${advert1.index != 0}">
                    <li data-target="#myCarousel" data-slide-to="${advert1.index}"></li>
                </c:if>
            </c:forEach>
        </ol>
        <!-- 轮播(Carousel)项目 -->
        <div class="carousel-inner">
            <c:forEach items="${advertList}" var="advert" varStatus="advert1">
                <c:if test="${advert1.index == 0}">
                    <div class="item active">
                        <img style="width: 100%;height: 350px" src="${advert.image}" alt="First slide">
                    </div>
                </c:if>
                <c:if test="${advert1.index != 0}">
                    <div class="item">
                        <img style="width: 100%;height: 350px" src="${advert.image}" alt="Second slide">
                    </div>
                </c:if>
            </c:forEach>
        </div>
        <!-- 轮播(Carousel)导航 -->
        <a class="carousel-control left" href="#myCarousel"
           data-slide="prev">&lsaquo;
        </a>
        <a class="carousel-control right" href="#myCarousel"
           data-slide="next">&rsaquo;
        </a>
    </div>
</div>

控制器

@RequestMapping(value = "http://www.mamicode.com/homepage")
    public String homepage(Model model) {
        // 获取广告对象
        List<CmsAdvert> advertList = cmsAdvertService.findList(new CmsAdvert());
        model.addAttribute("advertList", advertList);
        return "modules/cms/show/homepage";
    }

 

后台数据库取值 轮播图