Thymeleaf 异常:Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")

Spring Boot 项目,在 Spring Tool Suite 4, Version: 4.4.0.RELEASE 运行没有问题,将项目中的静态资源和页面复制到 IDEA 的项目中,除了 IDE 不同,其他基本相同。

运行 IDEA 中的项目,然后访问,出现异常:

Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")

具体异常:

  1 2019-12-10 21:37:40.896 ERROR 10276 --- [nio-8081-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8081-exec-1] Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")
  2
  3 org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")
  4     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241)
  5     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100)
  6     at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666)
  7     at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
  8     at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
  9     at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362)
 10     at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)
 11     at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
 12     at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
 13     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
 14     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
 15     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
 16     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
 17     at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
 18     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
 19     at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
 20     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
 21     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 22     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
 23     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 24     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 25     at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
 26     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 27     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 28     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 29     at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
 30     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 31     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 32     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 33     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
 34     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 35     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 36     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 37     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
 38     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
 39     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
 40     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
 41     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
 42     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
 43     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
 44     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
 45     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
 46     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
 47     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591)
 48     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
 49     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 50     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 51     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 52     at java.lang.Thread.run(Thread.java:748)
 53 Caused by: org.attoparser.ParseException: Error resolving template [_fragment], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 3, col 11)
 54     at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
 55     at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
 56     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
 57     ... 48 common frames omitted
 58 Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [_fragment], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 3, col 11)
 59     at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
 60     at org.thymeleaf.engine.TemplateManager.parseStandalone(TemplateManager.java:250)
 61     at org.thymeleaf.standard.expression.FragmentExpression.resolveExecutedFragmentExpression(FragmentExpression.java:588)
 62     at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.computeFragment(AbstractStandardFragmentInsertionTagProcessor.java:379)
 63     at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.doProcess(AbstractStandardFragmentInsertionTagProcessor.java:110)
 64     at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
 65     at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
 66     at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
 67     at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
 68     at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleOpenElementEnd(TemplateHandlerAdapterMarkupHandler.java:304)
 69     at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:278)
 70     at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleOpenElementEnd(OutputExpressionInlinePreProcessorHandler.java:186)
 71     at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:124)
 72     at org.attoparser.HtmlElement.handleOpenElementEnd(HtmlElement.java:109)
 73     at org.attoparser.HtmlMarkupHandler.handleOpenElementEnd(HtmlMarkupHandler.java:297)
 74     at org.attoparser.MarkupEventProcessorHandler.handleOpenElementEnd(MarkupEventProcessorHandler.java:402)
 75     at org.attoparser.ParsingElementMarkupUtil.parseOpenElement(ParsingElementMarkupUtil.java:159)
 76     at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:710)
 77     at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301)
 78     ... 50 common frames omitted
 79
 80 2019-12-10 21:37:40.900 ERROR 10276 --- [nio-8081-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
 81
 82 org.thymeleaf.exceptions.TemplateInputException: Error resolving template [_fragment], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "index" - line 3, col 11)
 83     at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
 84     at org.thymeleaf.engine.TemplateManager.parseStandalone(TemplateManager.java:250)
 85     at org.thymeleaf.standard.expression.FragmentExpression.resolveExecutedFragmentExpression(FragmentExpression.java:588)
 86     at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.computeFragment(AbstractStandardFragmentInsertionTagProcessor.java:379)
 87     at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.doProcess(AbstractStandardFragmentInsertionTagProcessor.java:110)
 88     at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
 89     at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
 90     at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
 91     at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314)
 92     at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleOpenElementEnd(TemplateHandlerAdapterMarkupHandler.java:304)
 93     at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:278)
 94     at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleOpenElementEnd(OutputExpressionInlinePreProcessorHandler.java:186)
 95     at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:124)
 96     at org.attoparser.HtmlElement.handleOpenElementEnd(HtmlElement.java:109)
 97     at org.attoparser.HtmlMarkupHandler.handleOpenElementEnd(HtmlMarkupHandler.java:297)
 98     at org.attoparser.MarkupEventProcessorHandler.handleOpenElementEnd(MarkupEventProcessorHandler.java:402)
 99     at org.attoparser.ParsingElementMarkupUtil.parseOpenElement(ParsingElementMarkupUtil.java:159)
100     at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:710)
101     at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301)
102     at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
103     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
104     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100)
105     at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666)
106     at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
107     at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
108     at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362)
109     at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)
110     at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
111     at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
112     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
113     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
114     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
115     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
116     at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
117     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
118     at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
119     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
120     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
121     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
122     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
123     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
124     at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
125     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
126     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
127     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
128     at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
129     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
130     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
131     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
132     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
133     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
134     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
135     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
136     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
137     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
138     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
139     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
140     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
141     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
142     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
143     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
144     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
145     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
146     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591)
147     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
148     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
149     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
150     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
151     at java.lang.Thread.run(Thread.java:748)

起初是直接运行项目,即 Shift + F10:

后来重新编译项目,再访问,就没有出现异常:

原文地址:https://www.cnblogs.com/Satu/p/12019465.html

时间: 2024-10-29 04:10:25

Thymeleaf 异常:Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")的相关文章

【报错】An error happened during template parsing (template: "class path resource [templates/hello1.html]")

页面显示: Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Fri Dec 06 23:26:03 CST 2019 There was an unexpected error (type=Internal Server Error, status=500). An error happened during templ

异常-Exception in thread "main" net.sf.jsqlparser.parser.TokenMgrError: Lexical error at line 1, column 596. Encountered: <EOF> after :

1 详细异常 Exception in thread "main" net.sf.jsqlparser.parser.TokenMgrError: Lexical error at line 1, column 596. Encountered: <EOF> after : at net.sf.jsqlparser.parser.CCJSqlParserTokenManager.getNextToken(CCJSqlParserTokenManager.java:3124)

【异常】Maxwell异常 Exception in thread &quot;main&quot; net.sf.jsqlparser.parser.TokenMgrError: Lexical error at line 1, column 596. Encountered: &lt;EOF&gt; after : &quot;&quot;

1 详细异常 Exception in thread "main" net.sf.jsqlparser.parser.TokenMgrError: Lexical error at line 1, column 596. Encountered: <EOF> after : "" at net.sf.jsqlparser.parser.CCJSqlParserTokenManager.getNextToken(CCJSqlParserTokenManag

Java 里的异常(Exception)详解

作为一位初学者, 本屌也没有能力对异常谈得很深入.   只不过Java里关于Exception的东西实在是很多. 所以这篇文章很长就是了.. 一, 什么是java里的异常 由于java是c\c++ 发展而来的,  首先我们先看看c语言里的错误. 1.1 c语言里的错误 我们实现1个程序的过程包括,  代码编写, 编译代码成为程序,  执行程序. . 其中大部分常见的语法错误都会被编译代码这样部过滤掉.   但是即使通过了编译. 执行程序这一步可能还是会有错误. 原因很多, 例如常见的除数为0,

JAVA学习--异常Exception

一.异常的体系结构 * java.lang.Throwable  *         |-----Error:错误,程序中不进行处理  *         |-----Exception:异常,要求在编写程序时,就要考虑到对这些异常的处理  *                 |-----编译时异常:在编译期间会出现的异常(执行javac.exe命令时,出现异常) *                 |-----运行时异常:在运行期间出现的异常(执行java.exe命令时,出现异常)  *  *

理解Python语言里的异常(Exception)

Exception is as a sort of structured "super go to".异常是一种结构化的"超级goto". 作为一个数十年如一日地钟爱C语言的程序员(因为C程序员需要记忆的关键字很少,而且可以很惬意地玩内存),对于高级语言如Python里的异常(Exception)一直不甚理解,尤其是其实现机理.但读了<Learning Python>一书中上面这句话(尤其是goto关键字)后,忽然豁然开朗. 如果用C语言编写一个鲁棒性良

浅谈java异常[Exception]

本文转自:focusJ 一. 异常的定义 在<java编程思想>中这样定义 异常:阻止当前方法或作用域继续执行的问题.虽然java中有异常处理机制,但是要明确一点,决不应该用"正常"的态度来看待异常.绝对一点说异常就是某种意义上的错误,就是问题,它可能会导致程序失败.之所以java要提出异常处理机制,就是要告诉开发人员,你的程序出现了不正常的情况,请注意. 记得当初学习java的时候,异常总是搞不太清楚,不知道这个异常是什么意思,为什么会有这个机制?但是随着知识的积累逐渐也

解决hiveserver2报错:java.io.IOException: Job status not available - Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

用户使用的sql: select count( distinct patient_id ) from argus.table_aa000612_641cd8ce_ceff_4ea0_9b27_0a3a743f0fe3; 下面做不同的测试: 1.beeline -u jdbc:hive2://0.0.0.0:10000 -e "select count( distinct patient_id ) from argus.table_aa000612_641cd8ce_ceff_4ea0_9b27_

PL/SQL 08 异常 exception

--PL/SQL错误  编译时  运行时 --运行时的出错处理  EXCEPTION --异常处理块DECLARE -BEGIN -EXCEPTION WHEN OTHERS THEN  handler_error(-);END; --用户自定义的异常DECLARE e_TooManyStudents EXCEPTION; -BEGIN - RAISE e_TooManyStudents; -EXCEPTION WHEN e_TooManyStudents THEN  -END; --预定义的O