Thymeleaf 异常:Exception processing template "index&a

时间:2022-05-14 06:49:46

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:

Thymeleaf 异常:Exception processing template "index&a

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

Thymeleaf 异常:Exception processing template "index&a