Bootstrap Carousel with SpringBoot RestAPI

In the tutorial, JavaSampleApproach will show you how to use Bootstrap Carousel with SpringBoot RestAPI.

Related posts:
Bootstrap Image with SpringBoot RestAPI
Bootstrap Image + MongoDB GridFsTemplate + SpringBoot RestAPI

I. Technologies

– Java 1.8
– Maven 3.6.1
– Spring Tool Suite – Version 3.9.0.RELEASE
– Bootstrap
– Spring Boot – 1.5.7.RELEASE

II. Goal – Bootstrap Carousel

Bootstrap provides Carousel plugin for slideshow elements. In the tutorial, we create a SpringBoot project with Bootstrap Carousel as below:

Bootstrap Carousel with SpringBoot RestAPI - project structure

-> results (.gif image):

Bootstrap Carousel with SpringBoot RestAPI - working demo

Implementation detail:

We have an outer div:

  • id="jsaAboutCarousel" is used to control properties of inside divs
  • .carousel class is used to tell to Bootstrap that is a carousel div
  • .slide class is used to animate images for moving
  • data-ride="carousel" is used to tells Bootstrap to start animating the carousel right after the page loads

Inside the above div, We have 3 divs: Indicators, Wrapper, and Left and right controls:

Indicators is used for the little dots at the bottom

  • carousel-indicators class is used to specify Indicator div
  • data-target class is used to point to the id of the carousel
  • data-slide-to class is used to specifies which the showing slide when having any clicking on the dot

Wrapper is specified by .carousel-inner class.

  • .item class is used to define a content of each slide (image or text)
  • .active is needed to be added for carousel visible

Left and right controls is used to add left and right buttons.

III. Practice

Step to do:
– Create SpringBoot project
– Create Web Controller
– Create RestAPI
– Create index.html

1. Create SpringBoot project

Using Spring Tool Suite to create a Spring Starter Project with needed dependencies:

2. Create Web Controller

3. Create RestAPI

4. Create index.html

IV. Sourcecode


By JavaSampleApproach | November 21, 2017.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *