SpringBoot页面静态化TemplateInputException错误解决

省流:仔细看错误提示,不一定是后台代码报错,可能错误出现在模板页面

1、在使用thymeleaf做页面静态化时,报了TemplateInputException错误:

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/detail.html]")

2、一执行templateEngine.process()就报错,经过108000秒的艰难排错后,发现问题出现在自己的模板页面,除了上面这个TemplateInputException(视图解析异常),向下看还有parseexception(运行时异常),具体错误如下:

Caused by: org.attoparser.ParseException: Link base "/course/list" cannot be context relative (/...) unless the context used for executing the engine implements the org.thymeleaf.context.IWebContext interface (template: "detail" - line 364, col 12)
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Link base "/course/list" cannot be context relative (/...) unless the context used for executing the engine implements the org.thymeleaf.context.IWebContext interface (template: "detail" - line 364, col 12)

3、经过报错提示,找到我的模板页面使用th:href="@{/course/list}"报了错,经过改正再次生成模板静态化页面,流畅运行。

 4、经验总结:

        1)一定要仔细看错误提示,本人因为没有仔细看报错提示,一直盯TemplateInputException(视图解析异常)找错误,白白浪费了几个小时。

        2)在确定后台代码没问题的前提下,检查一下模板页面,很有可能是模板页面出现了问题。

        3)这个问题不具有通用性。我的其他小伙伴也是下面的写法,就不会报错,具体原因,仍不清楚。

 5、求教:

        有没有大佬,可以解释一下,可能是什么地方导致了这个错误,为什么有人这么写的就不会报错呢?

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值