码迷,mamicode.com
首页 > 移动开发 > 详细

thymeleaf生成页面时报错:An error happened during template parsing (template: "class path resource [templates/index.html]")的解决办法

时间:2021-02-02 11:27:59      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:simple   tco   was   java   servlet   sdi   sock   NPU   config   

 

 

具体报错信息:

 1 Whitelabel Error Page
 2 This application has no explicit mapping for /error, so you are seeing this as a fallback.
 3 
 4 Mon Feb 01 21:33:07 CST 2021
 5 There was an unexpected error (type=Internal Server Error, status=500).
 6 An error happened during template parsing (template: "class path resource [templates/index.html]")
 7 org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")
 8     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241)
 9     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100)
10     at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666)
11     at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
12     at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
13     at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362)
14     at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189)
15     at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1394)
16     at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1139)
17     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1078)
18     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:961)
19     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
20     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
21     at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
22     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
23     at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
24     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
25     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
26     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
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.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
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.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
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.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
38     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
39     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
40     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
41     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
42     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
43     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
44     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
45     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
46     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
47     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
48     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
49     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
50     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
51     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
52     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
53     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
54     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
55     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
56     at java.lang.Thread.run(Thread.java:748)
57 Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "map.user.headerUrl" (template: "index" - line 123, col 13)
58     at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
59     at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
60     at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
61     ... 48 more
62 Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "map.user.headerUrl" (template: "index" - line 123, col 13)
63     at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:290)
64     at org.thymeleaf.standard.expression.VariableExpression.executeVariableExpression(VariableExpression.java:166)
65     at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:66)
66     at org.thymeleaf.standard.expression.Expression.execute(Expression.java:109)
67     at org.thymeleaf.standard.expression.Expression.execute(Expression.java:138)
68     at org.thymeleaf.standard.processor.AbstractStandardExpressionAttributeTagProcessor.doProcess(AbstractStandardExpressionAttributeTagProcessor.java:144)
69     at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74)
70     at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95)
71     at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633)
72     at org.thymeleaf.engine.ProcessorTemplateHandler.handleStandaloneElement(ProcessorTemplateHandler.java:918)
73     at org.thymeleaf.engine.StandaloneElementTag.beHandled(StandaloneElementTag.java:228)
74     at org.thymeleaf.engine.Model.process(Model.java:282)
75     at org.thymeleaf.engine.Model.process(Model.java:290)
76     at org.thymeleaf.engine.IteratedGatheringModelProcessable.processIterationModel(IteratedGatheringModelProcessable.java:367)
77     at org.thymeleaf.engine.IteratedGatheringModelProcessable.process(IteratedGatheringModelProcessable.java:293)
78     at org.thymeleaf.engine.ProcessorTemplateHandler.handleCloseElement(ProcessorTemplateHandler.java:1640)
79     at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleCloseElementEnd(TemplateHandlerAdapterMarkupHandler.java:388)
80     at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleCloseElementEnd(InlinedOutputExpressionMarkupHandler.java:322)
81     at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleCloseElementEnd(OutputExpressionInlinePreProcessorHandler.java:220)
82     at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleCloseElementEnd(InlinedOutputExpressionMarkupHandler.java:164)
83     at org.attoparser.HtmlElement.handleCloseElementEnd(HtmlElement.java:169)
84     at org.attoparser.HtmlMarkupHandler.handleCloseElementEnd(HtmlMarkupHandler.java:412)
85     at org.attoparser.MarkupEventProcessorHandler.handleCloseElementEnd(MarkupEventProcessorHandler.java:473)
86     at org.attoparser.ParsingElementMarkupUtil.parseCloseElement(ParsingElementMarkupUtil.java:201)
87     at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:725)
88     at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301)
89     ... 50 more
90 Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field headerUrl cannot be found on null
91     at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:213)
92     at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104)
93     at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:51)
94     at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:406)
95     at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:92)
96     at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:112)
97     at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:337)
98     at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:263)
99     ... 75 more

 

其实这句:

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

并没有什么用,只是告诉我们thymeleaf生成页面时出现了错误,具体错误还是在下面

Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "map.user.headerUrl" (template: "index" - line 123, col 13)

…………

Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "map.user.headerUrl" (template: "index" - line 123, col 13)

…………

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field headerUrl cannot be found on null

…………

 

说明   map.user.headerUrl  这个参数有问题,

网上说将  ${map.user.headerUrl}  改为  #{map.user.headerUrl}  

我改了后确实生成页面时不报错了,但是现实不出东西,如下图

 

技术图片

 

查阅$和#这两个的区别后(https://www.cnblogs.com/hjwublog/p/5051632.html)

发现这两个东西作用完全不同,这样改根本没意义,只是不报错而已,治标不治本

 

然后我把代码版本倒退一天,发现还是这个错误,而且只有index页面有这个错误,其他用户登录注册等页面都没有问题。

最后我在数据库中发现最近发的几个帖子的user_id字段都是0

技术图片

 

原来是我发帖时插入数据到数据库的时候没有设置user_id字段

技术图片

thymeleaf生成页面时报错:An error happened during template parsing (template: "class path resource [templates/index.html]")的解决办法

标签:simple   tco   was   java   servlet   sdi   sock   NPU   config   

原文地址:https://www.cnblogs.com/aojun/p/14359464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!