后台数据库取值 轮播图
Posted 随行-LV
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了后台数据库取值 轮播图相关的知识,希望对你有一定的参考价值。
<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">‹ </a> <a class="carousel-control right" href="#myCarousel" data-slide="next">› </a> </div> </div>
控制器
@RequestMapping(value = "homepage") public String homepage(Model model) { // 获取广告对象 List<CmsAdvert> advertList = cmsAdvertService.findList(new CmsAdvert()); model.addAttribute("advertList", advertList); return "modules/cms/show/homepage"; }
以上是关于后台数据库取值 轮播图的主要内容,如果未能解决你的问题,请参考以下文章
luffy-city 基础环境搭建(至轮播图前后台交互实现)-步骤目录