【发布时间】:2018-03-10 15:10:10
【问题描述】:
我是 Thymeleaf 的新手。我有一个 spring-boot 项目,我试图显示一些从 spring 控制器设置的属性值。
@Controller
public class HomeController {
@RequestMapping(path = "/info", method = RequestMethod.GET)
public String info(Model model) {
model.addAttribute("message", "Thymeleaf");
return "info";
}
}
请在我的 info.html 页面下方找到:
<!DOCTYPE html>
<html xmlns:thm="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Info</title>
</head>
<body>
<h1 thm:text="${message}"></h1>
</body>
</html>
请在我的 pom.xml 文件下方找到 [仅依赖项]
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
我知道 stackoverflow 中关于这个主题的帖子很少 我已经浏览了其中的几个,如下所示:
我已根据 stackoverflow 博客的建议相应地修改了我的 html 页面。但问题仍然存在。
我的网页根本没有渲染 Thymeleaf 文本。 谁能弄清楚确切的问题?
【问题讨论】:
标签: java spring spring-boot thymeleaf