今早打开昨天的项目,加了一个小功能,然后项目就崩了。主要是这个功能和这里一点关系都没有。
明明昨天晚上睡觉前都还好好的,今天一打开连首页都访问不了。崩溃。
花了一个多小时解决完这个问题,复盘错误时,把它还原成出错时的样子时它竟然又好了。我怀疑它在搞我心态。编程是门玄学问题。
来看看这个奇奇怪怪的bug吧
网页报错500
控制台:
```org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates//index.html]")
再看详细错误信息:
Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "map.user.headerUrl" (template: "/index" - line 123, col 12)
at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
... 48 common frames omitted
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "map.user.headerUrl" (template: "/index" - line 123, col 12)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'headerUrl' cannot be found on null
这是按照提示找到的index.html中出错的代码
<!-- 帖子列表 -->
<ul class="list-unstyled">
<li class="media pb-3 pt-3 mb-3 border-bottom" th:each="map:${discussPosts}">
<a href="site/profile.html">
<img th:src="${map.user.headerUrl}" class="mr-4 rounded-circle" alt="用户头像" style="