我正在用创建项目Springboot和Thymeleaf。我配置了整个项目,找到了模板和页面,所以我的模板找不到css和js文件;Thymeleaf在Springboot项目中找不到资源
我使用Springboot版本1.4.2.RELEASE。
的Html
application.properties
# --- CONFIGURAÇÃO TYMELEAF ---
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.cache=false
spring.thymeleaf.content-type=text/html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
spring.thymeleaf.enabled=true
WebMvcConfigurerAdapter
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/resources/")
.addResourceLocations("/static/")
.addResourceLocations("/static/**")
.addResourceLocations("/resources/static/")
.addResourceLocations("/resources/static/**")
.addResourceLocations("/")
.addResourceLocations("/**");
}
夹
UPDATE
我一样推荐并删除所有设置。所以这次我的页面打开,所以它不会加载起始页面。
指数
启动
Esse é o Prototipo do layout
Oi eu sou goku!!
2016-12-19
João
+1
spring-boot-starter-thymeleaf依赖关系附带的默认配置就是您需要的这种情况。尝试添加该jar并从Java配置文件和application.properties中删除您的自定义配置 –
+0
但是,没有必要至少配置前缀,后缀,上下文等...? –
+0
没有。如果您使用spring-boot-starter-thymeleaf依赖项,.html已经为您预先配置好了。并且spring-boot-starter-web会自动为src/main/resources/{public,static或resources}中的任何文件提供服务/ ** –