首页 > 解决方案 > 我如何在春季启动中为百里香设置前缀路径

问题描述

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

我有一个弹簧启动应用程序。我使用的是 2.1.7 版。

标签: spring-boot

解决方案


在 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

推荐阅读