我从springboot的一个项目开始,我有一个以前从未见过的错误,我还没能解决它,这是因为胸腺细胞依赖关系不起作用,我和intellij idea社区版一起工作。它不允许我使用th:文本,请看图片。我删除了这个项目并重新下载了几次,删除了m2文件夹,但是没有什么对我有用。
这是我的控制器:
@Controller
public class IndexController {
@GetMapping(value = "/index")
public String index(Model model){
model.addAttribute("titulo", "nombre");
return "index";
}
}这是de index.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>th:text="${titulo}"</title>
</head>
<body>
</body>
</html>当我运行代码localhost不向我显示正确的信息时,我已经安装了依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>发布于 2022-04-08 06:02:32
您的模板被用作静态资源。控制器对/index有一个映射,但是您已经访问了http://localhost:8080。要么将映射更改为@GetMapping("/"),要么访问http://local host:8080/index。您还应该检查index.html在项目中的位置。应该在src/main/resources/templates里。
https://stackoverflow.com/questions/71791868
复制相似问题