1 回答

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊
Thymeleaf 和 JSP 是兩種不同的服務(wù)器端渲染模板。沒(méi)有配置你不能同時(shí)使用它們。
根據(jù)您的代碼,您應(yīng)該更新使用 Thymeleaf 的設(shè)置
:將 home.jsp 更改為 home.html
b. 將 home.html 移動(dòng)到路徑:src/main/resources/templates
c。在 application.properties 中配置 Thymeleaf:
? ?# Thymeleaf
? ?spring.thymeleaf.prefix=classpath:/templates/
? ?spring.thymeleaf.suffix=.html
? ?spring.thymeleaf.encoding=UTF-8
? ?spring.thymeleaf.mode=HTML5
? ?spring.thymeleaf.cache=false
d. 在 pom.xml 中配置 Thymeleaf 依賴
<dependency>?
? ? <groupId>org.springframework.boot</groupId>?
? ? <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
對(duì)于Viewing templates,SpringBoot推薦使用Thymeleaf而不是JSP
在SpringBoot應(yīng)用中同時(shí)使用Thymeleaf和JSP,還需要配置更多。
添加回答
舉報(bào)