Контроллер имеет,
package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
/**
* GreetingController
*/
@Controller
public class GreetingController {
@GetMapping("/index")
public String greeting(Model model) {
String[] dataa = {"TATA", "CTS", "MTS"};
model.addAttribute("message", "Hello world!");
model.addAttribute("datta", dataa);
return "index";
}
}
индекс Thymeleaf. html:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h2>Index Page2</h2>
<h1 th:text="${message}"></h1>
<ul th:each="item : ${datta}">
<li th:text="${item}"></li>
</ul>
</body>
</html>
Not usnderstanidng, почему я не могу использовать массив данных в индексе. html. Возможно ли установить значение ключа th: each.