云飞 ° 2020-05-30 14:47 采纳率: 25%
浏览 1579
已采纳

springboot报错template: "class path resource [templates/index.html]"

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")
	at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241)



Caused by: org.attoparser.ParseException: Error resolving template [_fragments], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 5, col 7)
	at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)



Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [_fragments], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 5, col 7)
	at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)




2020-05-30 14:37:12.099 ERROR 5344 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")] with root cause


org.thymeleaf.exceptions.TemplateInputException: Error resolving template [_fragments], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 5, col 7)
	at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
  • 写回答

21条回答 默认 最新

  • sh_c_1314 2020-05-30 17:52
    关注

    因为没有id为head的fragment的存在于_fragments下 ,所以没有解析找到他,你首先要创建一个(_fragments) html在其中创建一个id为head的fragment,

    才能在index.html中用th:replace来引用他:

    可以参考:

    https://www.cnblogs.com/heavenbird/articles/9644985.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(20条)

报告相同问题?

问题事件

  • 已采纳回答 12月1日

悬赏问题

  • ¥15 CCF-CSP 2023 第三题 解压缩(50%)
  • ¥30 comfyui openpose报错
  • ¥20 Wpf Datarid单元格闪烁效果的实现
  • ¥15 图像分割、图像边缘提取
  • ¥15 sqlserver执行存储过程报错
  • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
  • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
  • ¥100 matlab2009 32位一直初始化
  • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
  • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数