Springboot项目打包后thymeleaf模板无法解析的问题(附带源码分析问题)

在将Springboot项目打包并部署到Docker后,遇到Thymeleaf模板无法解析的问题,报错显示TemplateInputException。经过查看docker日志,发现是视图名错误。解决方案是修正Controller中返回的视图名,去除额外的'/'前缀。问题在于Springboot自动配置的SpringMVC路径已包含'/',本地运行成功的原因尚不明确。

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

查看docker日志报错:

ERROR 1 — dispatcherServlet : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/emp/update], templax
te might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/emp/update], template might not exist or might not be accessible by any of the configured Template Resolvers

解决方法

经查询后发现是我controller返回的视图名写成了/emp/update
将视图名改为emp/update即可正常访问

原因

在这里插入图片描述
通过分析源码

 priva
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值