This Tutorial is a quick starter for Spring Web Application using Spring Boot + ThymeLeaf, follow the below 5 easy steps to run your very first Spring Web Application in less than 5 minutes,
Step 1: Setup Spring Web Workspace using Spring Initializr
- Open IntelliJ IDE,
- Create New Project,
- Select Spring Initializr
- Select the Project SDK (I have selected Java SDK 1.8)
- Click Next,
- Select Project Type as Gradle Project
- Java Version (8 in my case)

- Select Dependencies: Spring Web and Thymeleaf

- Click Next
- Click Finish
- If IntelliJ prompts click on "Load Gradle Project"
Step 2: Create Sping Web Controller
Under src > main > java com.example.demo, create MyHelloController.java
package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class MyHelloWorldController {
@GetMapping("/hello-world")
public String greeting() {
return "helloWorld";
}
}
Step 3: Create Thymeleaf HTML Page
Navigate to src > main > resources > templates and create file helloWorld.html
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring Web + Thymeleaf - Hello World Example!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
Step 4: Run the Spring Web Application
Navigate to src > main > java com.example.demo and open DemoApplication and Run the main method.
Step 5: View Results on Web Broswer
Now open any Web Brower (Safari, Chrome, Firefox, or Edge) and open URL: http://localhost:8080/hello-world

Download this project from GitHub: https://github.com/code2care/spring-web-thymeleaf-hello-world-example/tree/main/demo
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!