thymeleaf找不到html文件,Thymeleaf在Springboot项目中找不到资源

我正在用创建项目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("/**");

}

9EKP8.jpg

UPDATE

我一样推荐并删除所有设置。所以这次我的页面打开,所以它不会加载起始页面。

指数

启动

Esse é o Prototipo do layout

Oi eu sou goku!!

3HTDy.jpg

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}中的任何文件提供服务/ ** –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值