Software Development, Spring Boot

Spring MVC with Spring Boot, Kotlin, and Thymeleaf

This post shows a sample Spring MVC application developed with Spring Boot, Kotlin, and Thymeleaf. Generally speaking, it is now possible and safe to port your Java-based Spring MVC application codes to Kotlin or start writing new Spring MVC applications in Kotlin already.


This section lists the Software used for this post.

  1. Windows 10 Enterprise Edition 64bit
  2. JDK 8
  3. IntelliJ IDEA Ultimate 2016.3
  4. Spring Boot 1.5.4.RELEASE
  5. Kotlin Version 1.1

The Spring MVC Application

The sample application is quite simple but has the following URLs will associated functionalities.


/studentsGETLists all student records
/student/{studentId}GETSearches for a student record by Id
/studentPOSTCreates a new student record and displays it
/studentGETDisplays the form where users input the student data and submit the form to create a new student record in the application
/GETDisplays an index page

Testing the Spring MVC Application

Showing the Index page

Listing all existing student records

Displaying specific student record


Displaying the New Student Form/Page

On click the Submit button, the user is redirected to page shown below.

Creating The Spring MVC Application

Okay, we’ve gone through the fairly simple UI of our sample application. Now, let’s see how is was created step-by-step.

1. File -> New -> Project…

Choose Spring Initialzr and click Next.

2. Provide project details

Choose Kotlin and click Next.

3. Choose Spring Boot components

Choose Web and Thymeleaf. Click Next to proceed.

4. Provide additional information

Click Finish to complete the process.

Once done. We’ll have the following initial project files and structure.

Coding, coding, coding

The application has the following files added to it.


The Controllers and Pages

There are 2 controllers and 4 HTML files.

The Index Controller

This displays the index page index.html

Controller codes

The Page

The Student Controller

This controller displays various pages depending on URL.

The Domain and Service

The class may represent a JPA entity or data coming from some data source.


The class provides codes to retrieve, and add Student records.

Down the codes




Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like