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

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 利用决策森林为什么会出现这样·的问题(关键词-情感分析)
  • ¥30 logisim中设计一个位于十字路口的交通信号灯控制系统
  • ¥15 DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI[/untitled30_war_e
  • ¥15 使用deepspeed训练,发现想要训练的参数没有梯度
  • ¥15 寻找一块做为智能割草机的驱动板(标签-stm32|关键词-m3)
  • ¥15 信息管理系统的查找和排序
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),怎么用读取的电磁传感器信号表示小车所在的位置
  • ¥15 如何解决y_true和y_predict数据类型不匹配的问题(相关搜索:机器学习)
  • ¥15 PB中矩阵文本型数据的总计问题。
  • ¥15 MATLAB卫星二体模型仿真