Spring Boot 模版ThymeLeaf 路径配置

在Spring Boot微服务开发中,ThymeLeaf被推荐用于替代jsp作为前端模板。在实践过程中,作者遇到Controller转发到html页面时定位失败的问题,错误显示在Console和浏览器中。解决方案在于在配置返回页面URL前缀时需添加classpath:,这一经验可供其他开发者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近学习Spring Boot微服务开发,参考一个很不错的微信公众号学习,分享一个链接:点击打开链接  博主:纯洁的微笑

开始的入门学习很简单,很简单的搭建过程,很精简的项目依赖配置,完成很简单的 HelloWorld!

接下来遇见一个小坑,这里记录一下,供大家学习参考:

SpringBoot推荐前台使用ThymeLeaf代替以往的jsp页面,具体的优势大家自己体验吧;

我遇到的问题是,在使用ThymeLeaf方式,Controller转发定位不到正确的html页面,错误内容如下:

Console显示:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers
	at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymele
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值