如果用户登录,我会从我的ApplicationAdvice
班级获得一个 currentUser 并在每个页面上显示它:
@ModelAttribute("currentUser")
public TmtUser currentUser(Model model) {
TmtUser currentUser = TmtUser.currentUser;
model.addAttribute("currentUser", currentUser);
return currentUser;
}
该currentUser
对象有一个url
可用的属性。但我在将 url 呈现到页面时遇到错误。也许在提供url
值之前渲染了 DOM?我怎么会知道?
HTML:
<img th:src="${currentUser.get('profilePicture').get('url')}" src="" />
例外:
Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "currentUser.get('profilePicture').get('url')" (template: "fragments/header" - line 72, col 139)
at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) ~[attoparser-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.attoparser.MarkupParser.parse(MarkupParser.java:257) ~[attoparser-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
... 105 common frames omitted
对象模型:
浏览器控制台错误:
org.parse4j.ParseFile@190687b3 Failed to load resource: the server responded with a status of 404 ()
似乎 ParseFile 本身没有在浏览器中加载。