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

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日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度