[JAVA] Build a WEB system with Spring + Doma + H2DB + Thymeleaf


I used to do Build a WEB system with Spring + Doma + H2DB, but I tried to create a page using Thymeleaf as a template engine. think.

Environmental preparation

Use the previous project as is. First, add the following to pom.xml.



Creating HTML and Controller

First, add the HTML file. This time add test.html. The place to add is src / main / resources / templates.


<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
		<meta charset="UTF-8">
				<tr th:each="entity : ${entities}" th:object="${entity}">
					<td th:text="*{id}">id</td>
					<td th:text="*{name}">name</td>

Finally, add a method for displaying HTML to Controller. Add the following method to TestController.java.


@RequestMapping(value = "test_th", method = RequestMethod.GET)
public String getEntitiesHtml(Model model) {
	List<TestEntity> list = service.getAllEntities();
	model.addAttribute("entities", list);
	return "test";

Change the annotation attached to the class from @ RestController to @ Controller.


public class TestController {

Try to move

When I accessed [http: // localhost: 8080 / test_th](http: // localhost: 8080 / test_th), the data was safely displayed in table format. test.png

Recommended Posts

Build a WEB system with Spring + Doma + H2DB + Thymeleaf
Build a WEB system with Spring + Doma + H2DB
Build a WEB system with Spring + Doma + H2DB Part 2
Build a web application with Javalin
Run WEB application with Spring Boot + Thymeleaf
Create a web api server with spring boot
Build Doma1 with Ant
The first WEB application with Spring Boot-Making a Pomodoro timer-
Create a Hello World web app with Spring framework + Jetty
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
Implement a simple Web REST API server with Spring Boot + MySQL
Let's make a book management web application with Spring Boot part1
Build a Java project with Gradle
Build a Node.js environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Database linkage with doma2 (Spring boot)
Let's make a book management web application with Spring Boot part3
Let's make a book management web application with Spring Boot part2
Authentication / authorization with Spring Security & Thymeleaf
Spring Boot gradle build with Docker
Create a simple web application with Dropwizard
Build a PureScript development environment with Docker
Create a simple on-demand batch with Spring Batch
Start web application development with Spring Boot
Build a Wordpress development environment with Docker
De-cron! Build a job scheduler with Rundeck
Implement CRUD with Spring Boot + Thymeleaf + MySQL
Implement paging function with Spring Boot + Thymeleaf
I tried to clone a web application full of bugs with Spring Boot
Create a website with Spring Boot + Gradle (jdk1.8.x)
Create a simple search app with Spring Boot
Make HTML page dynamic with thymeleaf (spring + gradle)
04. I made a front end with SpringBoot + Thymeleaf
Build a Laravel / Docker environment with VSCode devcontainer
Build a WordPress development environment quickly with Docker
How to use built-in h2db with spring boot
Build Spring Boot project by environment with Gradle
Create CRUD apps with Spring Boot 2 + Thymeleaf + MyBatis
[Win10] Build a JSF development environment with NetBeans
Create your own Utility with Thymeleaf with Spring Boot
Creating a common repository with Spring Data JPA
Create a Spring Boot development environment with docker
Build a Java development environment with VS Code
Create a web app that is just right for learning [Spring Boot + Thymeleaf + PostgreSQL]
A story that stumbled when deploying a web application created with Spring Boot to EC2