DoMyDissertations delivers custom writing services to “persuasive essay for highschool students” and “write my dissertation” requests from students worldwide. Before ordering services with our company, please, get acquainted with our Terms and Conditions, Privacy Policy and Revision Policy, available for customer review. fbarro/ November 23, 2018/ Spring Boot/ 2 comments

Affordable custom essay net review. Hire a freelance legal writing expert services and get your legal writing & research work done within 24hr

Order your thesis or dissertation from the Home Page service on the market. And not only that – you can now enjoy 20% OFF on first order! The objective of this tutorial is to create a simple application using Spring Boot and Thymeleaf.

So what is Thymeleaf?

in a persuasive essay develop your argument order a custom essay best resume writing services for educators guide technology good or bad essay Thymeleaf is a server-side design template engine for Java. It has built-in support for Spring framework and it is also broadly used in Spring based Projects. As a matter of fact, Spring Boot has been promoting Thymeleaf in a number of Spring Boot examples in it’s blog site. Essay Basics Is The Best College Essay Writing Service, 24/7 Support, 10 Years Of Experience In Academic Writing, USA Based Company! Tools We will Need:

  1. Spring Boot 2.1.1.RELEASE
  2. Spring 5.1.3.RELEASE
  3. Thymeleaf RELEASE
  4. Embedded Tomcat 8
  5. Maven
  6. Java 8

1. Create Spring Boot project template offers you a wide range of academic writing services. We have only pro writers in our team. High quality guaranteed. We will start by creating Spring Boot project by Bootstrapping with Spring Initializr. Open Spring Initializr ( ) in your browser and generate the project with the following inputs:

Amazing UK online homework help australia Service. We tend to like custom-made products, although most of us do not buy a lot of them. They are usually more Spring Boot - Spring Initializr

Many Students have a query,who can do my assignment for answer to your query “ To Do Your Assignment Online Click the Generate Project button to download the project’s zip file. Extract the file in your workspace and import it in your preferred IDE (for our tutorial we will be using Eclipse). The project’s directory structure should look like this:

Spring Boot - Folder Structure
Directory structure of Spring Boot project.

2. Import Spring Boot project to Eclipse

a. Import the Spring Boot project as existing maven project.

Import the Spring Boot project as existing maven project.
Import the Spring Boot project as existing maven project.

b. Select the pom.xml inside your project folder then click Finish to import it.

Select the pom.xml inside your project folder
Select the pom.xml inside your project folder.

c. Project will be imported and all the dependencies you have declared in pom.xml will be automatically downloaded and added into classpath.

Project Dependencies as described in pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
		<relativePath/> <!-- lookup parent from repository -->
	<name>Spring Boot Web Thymeleaf Demo</name>
	<description>Spring Boot Web Thymeleaf Demo</description>

3. Create a Web Controller

First, Let’s add a new package called “controller” under com.affinityjava.demo, and then create a file inside that package. The Controller class will look like this:

package com.affinityjava.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
public class HelloController {
    public String sayHello(Model model,
    				     required=false, defaultValue="World") String name) {
        model.addAttribute("name", name);
        return "hello";

Let’s break down the annotations of the

@Controller – annotation which mark a class as HTTP request handler.
@GetMapping – annotation for mapping HTTP GET requests onto specific handler methods. It maps /hello request to sayHello() method.

@GetMapping is a shortcut for @RequestMapping(method = RequestMethod.GET)

@RequestParam – annotation to retrieve the URL parameter and bind it to the method argument. It binds value of String parameter “name” into name parameter of sayHello() method. The “name” URL parameter is not required ( required=false ), so we assigned a defaultValue ( defaultValue="World" ) when the request parameter is not provided.

Next, we added the value of the “name” parameter to a Model object, so it is accessible from the view template.

Finally, we returned the template name which will be used to render the response to the browser.

4. Create a Thymeleaf Template

Create a new file called hello.html inside in resources -> templates directory with the following contents:

<html xmlns:th="">
    <title>Getting Started with Spring Boot and Thymeleaf</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="/css/main.css" />
    <h1 th:text="|Hello ${name}!|"></h1>

As you can see in the view template above, we have used a th:text Thymeleaf attribute. Thymeleaf parses the hello.html template and evaluates the th:text attribute to render the value of the ${name} parameter that was set in the controller.

5. Adding Static Files

Create a new folder called css in the static folder and then create a file main.css inside static/css.

In Spring Boot, we can add static files like CSS or Javascript inside /src/main/resources/static/.

body {
    background: #bf5024;
    background: -webkit-linear-gradient(to right, #185a9d, #43cea2);
    background: linear-gradient(to right, #10375f, #ce5d43);
    color: #fff;
h1 {
    font-size: 42px;
    margin: 14px;

Run the Hello World Application

Go to application folder and type the following command:

$ mvn spring-boot:run

Once Spring Boot is successfully started, you can access the application in your browser – http://localhost:8080/greet

Output for Hello World Program.
Output for http://localhost:8080/greet

Or provide a name parameter – http://localhost:8080/greet?name=Affinity

Output for Hello World Program.
Output for http://localhost:8080/greet?name=Affinity


Congratulations folks! We have just developed a simple application using Spring Boot and Thymeleaf.

Thank you for reading. If you have questions, please feel free to drop us a message in the comment section below. Happy Learning!

Share this Post


  1. Hi, very nice website, cheers!
    Need cheap and reliable hosting? Our shared plans start at $10 for an year and VPS plans for $6/Mo.
    Check here:

Leave a Comment

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>