我如何在 Spring Boot 中设置 thymeleaf 的前缀路径

Dee*_*rma 8 spring-boot

如何设置前缀路径(设置新目录)来渲染 HTML 页面?

我有一个春季启动应用程序。我使用的是2.1.7版本。

  • 我设置了查看页面的新路径。

小智 6

在 Application.properties 中添加以下行

spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/views/    #this is the main
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false
spring.main.allow-bean-definition-overriding=true
Run Code Online (Sandbox Code Playgroud)