WARN 18868 --- [ main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: cla

springBoot + thymeleaf: 访问login页面报错
idea 项目
找不到@Controller 以String方式返回的页面


原因: thymeleaf 默认返回的页面在/resource/templates下,
即template-loader-path: classpath:/templates


1、如果放在其他地方可能引起找不到

暂时不知道怎么修改

spring:
  thymeleaf:
    cache: false
    mode: HTML5
    encoding: utf-8
    content-type: text/html
    template-loader-path: classpath:/templates
    suffix: .html

2、如果template-loader-path: classpath:/templates 后面没有"/",那么return的字符串要以"/"开头

如:
classpath:/templates 对应 /pages/login/loginPage
classpath:/templates/ 对应 pages/login/loginPage

3、pom 文件中要引入相关的包

<!-- thymeleaf模板引擎 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
    <version>2.2.5.RELEASE</version>
</dependency>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值