12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
编程知识 时间:2024-11-19 11:54:03
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
首先,在pom.xml文件中添加Thymeleaf的依赖:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>
spring.thymeleaf.prefix=classpath:/templates/spring.thymeleaf.suffix=.html
@Controllerpublic class MyController {@RequestMapping("/myPage")public String myPage(Model model) {model.addAttribute("message", "Hello, Thymeleaf!");return "myPage";}}
<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org"><head><title>My Page</title></head><body><h1 th:text="${message}"></h1></body></html>
通过以上步骤,就可以实现Spring Boot整合Thymeleaf的功能。
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19