请选择 进入手机版 | 继续访问电脑版
本站特色:极好的技术研究氛围!所有技术交流,必有回复!

疯狂Java联盟

 找回密码
 加入联盟
查看: 426|回复: 0

Thymeleaf模板引用异常

[复制链接]
发表于 2018-2-13 16:58:30 | 显示全部楼层 |阅读模式
在一般的环境中(非web环境)使用Thymeleaf时,引用模板需要使用以下语法:

  1. <div th:insert="~{footer.html :: copy}"></div>
复制代码


其中footer.html是模板片断文件,如果不带有.html后缀,则会得到以下异常:

  1. Exception in thread "main" org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "footer" - line 3, col 8)
  2.         at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:235)
  3.         at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100)
  4.         at org.thymeleaf.engine.TemplateManager.parseStandalone(TemplateManager.java:302)
  5.         at org.thymeleaf.standard.expression.FragmentExpression.resolveExecutedFragmentExpression(FragmentExpression.java:588)
  6.         at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.computeFragment(AbstractStandardFragmentInsertionTagProcessor.java:399)
  7.         at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.doProcess(AbstractStandardFragmentInsertionTagProcessor.java:110)
  8.         at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
  9.         at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
  10.         at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
  11.         at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
  12.         at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205)
  13.         at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136)
  14.         at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:661)
  15.         at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
  16.         at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1059)
  17.         at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1048)
  18.         at org.crazyit.boot.c7.IncludeTest.main(IncludeTest.java:18)
  19. Caused by: java.io.FileNotFoundException: ClassLoader resource "footer" could not be resolved
  20.         at org.thymeleaf.templateresource.ClassLoaderTemplateResource.reader(ClassLoaderTemplateResource.java:130)
  21.         at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:223)
  22.         ... 16 more
复制代码


您需要登录后才可以回帖 登录 | 加入联盟

本版积分规则

小黑屋|手机版|Archiver|疯狂Java联盟 ( 粤ICP备11094030号 )

GMT+8, 2018-8-15 09:43 , Processed in 0.303269 second(s), 6 queries , File On.

快速回复 返回顶部 返回列表