Пытаюсь реализовать структуру станиц по шаблону Thymleaf? но получаю такую ошибку -
ERROR [org.thymeleaf.TemplateEngine] (default task-1) [THYMELEAF][default task-1] Exception processing template "index": An error happened during template parsing (template: "ServletContext resource [/WEB-INF/view/index.html]"): org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "ServletContext resource [/WEB-INF/view/index.html]")
Подскажите где я ошибся или скинте пожалуйста туториал где настраивается это все.
Структура папок
По дефолту закгружаюсь на index.html
Контроллер
@Controller
public class MainController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model){
model.addAttribute("in", "Hello index");
return "index";
}
@RequestMapping(value = "/main" ,method = RequestMethod.GET)
public String goMain(Model model){
model.addAttribute("message", "Hello Spring5");
System.out.println("main");
return "main";
}
@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home(Model model){
model.addAttribute("message", "Hello home");
System.out.println("home");
return "home";
}
}
spring-servlet.xml
<context:component-scan base-package="com.controller"/>
<mvc:annotation-driven/>
<context:annotation-config/>
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="templateResolve" class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".html"/>
<property name="templateMode" value="HTML"/>
<property name="cacheable" value="false"/>
</bean>
<bean id="templateEngine"
class="org.thymeleaf.spring5.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolve"/>
<property name="additionalDialects">
<set>
<bean class="nz.net.ultraq.thymeleaf.LayoutDialect"/>
</set>
</property>
</bean>
<bean class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<property name="order" value="1" />
<property name="viewNames" value="*" />
</bean>
Шаблон layout
<!DOCTYPE html>
<html xmlns = "http://www.w3.org/1999/xhtml"
xmlns:th = "http://www.thymeleaf.org"
xmlns:layout = "http://www.ultraq.net.nz/thymeleaf/layout">
<head th:replace="thymeleaf/header :: header">
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div th:replace="thymeleaf/navigation :: navigation"></div>
<div layout:fragment="content">
</div>
<div th:replace="thymeleaf/footer :: footer"></div>
</body>
</html>
Страница index.html
!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
layout:decorate="~{resources/layout}">
<head>
<!--<title>Title</title>-->
</head>
<body>
<h1>INDEX PAGE это в папку скрытой</h1>
<!--<h2 th:text="${in}"></h2>-->
</body>
</html>