我是 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 文本。任何人都可以弄清楚确切的问题吗?
thm
不是 Thymleaf 中的有效前缀,请<h1 th:text="${message}"></h1>
改用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句