At startup, the spring application works with view, but the html code is highlighted in red when it is written, respectively, it is not convenient to look for errors in html, here are photos and code of html and the controller: (https://i.stack.imgur.com/RDPvL.png) (https://i.stack.imgur.com/Bm1vQ.png)
package com.nikita.al_fp.controllers;
import com.nikita.al_fp.entity.Book;
import com.nikita.al_fp.entity.Person;
import com.nikita.al_fp.service.BookService;
import com.nikita.al_fp.service.PersonService;
import com.nikita.al_fp.util.BookValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@Controller
@RequestMapping("/book")
public class BookController {
private final BookValidator bookValidator;
private final PersonService personService;
private final BookService bookService;
public static final String BOOK_REDIRECT_PAGE = "redirect:/book";
@Autowired
public BookController(BookValidator bookValidator, PersonService personService, BookService bookService) {
this.bookValidator = bookValidator;
this.personService = personService;
this.bookService = bookService;
personService.startProgramProcessPerson();
bookService.startProgramProcessBook();
}
@GetMapping
public String selectBook(Model model) {
model.addAttribute("books", bookService.findAll());
return "/book/select_book";
}
}
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Select Book</title>
</head>
<body>
<div th:each="book : ${books}">
<a th:href="@{/book/{id}(id=${book.getId()})}"
th:text="${book.getName() + ', ' + book.getAuthor() + ', ' + book.getYear()}">book</a>
<br/>
</div>
<br/>
<hr/>
<a href="/book/new">Add book</a>
<br>
<a href="/people">Show User List</a>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.nikita</groupId>
<artifactId>al_fp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>al_fp</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
I tried to find a solution on the Internet, unsuccessfully, but views work when app runned