1 回答
TA贡献1826条经验 获得超6个赞
Thymeleaf 和 JSP 是两种不同的服务器端渲染模板。没有配置你不能同时使用它们。
根据您的代码,您应该更新使用 Thymeleaf 的设置
:将 home.jsp 更改为 home.html
b. 将 home.html 移动到路径: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>
对于Viewing templates,SpringBoot推荐使用Thymeleaf而不是JSP
在SpringBoot应用中同时使用Thymeleaf和JSP,还需要配置更多。
添加回答
举报
