springboot集成thymeleaf报错:template might not exist or might not be accessible by any of the configured

0、报如下错误:

xyAdmin- 2025-02-10 20:38:22 [http-nio-443-exec-1] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][http-nio-443-exec-1] Exception processing template "1webSitePages/defaultPages/websocketTest.html": Error resolving template [1webSitePages/defaultPages/websocketTest.html], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [1webSitePages/defaultPages/websocketTest.html], template might not exist or might not be accessible by any of the configured Template Resolvers
	at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
	at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
	at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366)
	at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1406)

1、引入依赖,引入如下依赖

        <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>

2、配置文件如下,以下是windows的配置,如果是Linux系统,那prefix的直接是路径/home/xyAdmin/thymeleafTemplate/

  spring:
    thymeleaf: 
      cache: false
      prefix: file:/D:/home/xyAdmin/thymeleafTemplate/
      suffix: .html
      encoding: utf-8
      mode: HTML

泣血要记住的内容:刚开始我的地址是配置到jar包中,直接可以访问。但是由于需求变动,需要把模板放到jar外面,好可以直接替换模板。就按照网上说的例子一样,配置了spring.thymeleaf.prefix的路径,其实这样就直接可以用了。但是我应该是脑袋被撞了,没有想清楚。还专门弄了个@Vaule把这个参数放到代码里面读取出来,然后进行地址拼接。导致一直在报标题上面的错误。这么傻的问题,还被困扰了几个小时,一直在纠结为什么不行,真的是脑壳被夹了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值