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

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 09:52
    关注

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

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

    可以参考:

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

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部