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
Have Questions? Post them here!
- Drop table using Java JDBC Template
- Java - Check if array contains the value
- YAML Parser using Java Jackson Library Example
- Java Jackson ObjectMapper Class with Examples
- Get Client IP address from HTTP Response in Java
- How to Word-Warp Console logs in IntelliJ
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass
- Setting Java_Home Environment variable on Windows Operating System
- Fix: Maven - Failed to execute goal - Compilation failure - Source/Target option 5 is no longer supported. Use 7 or later
- Java SE JDBC Select Statement Example
- How to extract Java Jar/War/Ear files in Linux
- java: unclosed string literal [Error]
- [Solution] Exception in thread main java.util.EmptyStackException
- Read YAML file Java Jackson Library
- What Java version is used for Minecraft 1.18
- [Java] How to throws Exception using Functional Interface and Lambda code
- [Program] How to read three different values using Scanner in Java
- Java 8 Predicate Functional Interface Examples
- Display Era details (AD BC) in Java Date using SimpleDateFormat
- Convert String Date to Date Object in Java
- Struts 2 Hello World Example in Eclipse
- Read a file using Java 8 Stream
- Java - How to set custom thread name?
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- java: ']' expected error [fixed]
- java.lang.NoClassDefFoundError android.support.v4.content.LocalBroadcastManager - Android
- JavaScript : Get current page address - JavaScript
- VS Code Remove Unused Imports Keyboard Shortcut - HowTos
- Git Config Command - A Deep Dive - Git
- How to Close Safari in Mac using Keyboard shortcut - MacOS
- Fix Microsoft Teams Admin Center error - The Security zone setting isn't configured correctly - Teams
- How to List the SHA Digest of Docker Images - Docker
- [fix] fatal: this operation must be run in a work tree in git - Git