Я следил за руководством по началу работы это и следующей ошибкой:
org.thymeleaf.exceptions.TemplateProcessingException: Ошибка при выполнении процессора org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor (шаблон: "index" - строка 10, столбец 31) "
Код точно такой же, как в руководстве. Я понимаю, что это как-то связано с тегом формы Thymeleaf, поэтому я также проверил Документация Thymeleaf, но не смог понять, что не так с моим кодом.
Вот код:
index.html
<!DOCTYPE HTML>
<html xmlns:th = "http://www.thymeleaf.org">
<head>
<title>Getting Started: Handling Form Submission</title>
<meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" />
</head>
<body>
<h1>Form</h1>
<form action = "#" th:action = "@{/greeting}" th:object = "${greeting}" method = "post">
<p>Id: <input type = "text" th:field = "*{id}" /></p>
<p>Message: <input type = "text" th:field = "*{content}" /></p>
<p><input type = "submit" value = "Submit" /> <input type = "reset" value = "Reset" /></p>
</form>
</body>
</html>
GreetingController.java
package com.example;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class GreetingController {
@GetMapping("/greeting")
public String greetingForm(Model model) {
model.addAttribute("greeting", new Greeting());
return "greeting";
}
@PostMapping("/greeting")
public String greetingSubmit(@ModelAttribute Greeting greeting) {
return "result";
}
}
Greeting.java
package com.example;
public class Greeting {
private long id;
private String content;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
Буду признателен за любой совет.




Итак, в руководстве говорится, что вам нужно создать 2 файла: result.html и greeting.html. И вы создали index.html. Дело в том, что вы не привязывали страницу шаблона к контроллеру Spring, он привязан к greeting.html, как в tuturial.
Итак, решение - просто изменить возврат с приветствие на показатель в методе greetingForm():
@GetMapping("/greeting")
public String greetingForm(Model model) {
model.addAttribute("greeting", new Greeting());
return "index"; // <- changed line
}
Надеюсь, это поможет тебе.