0
靜態圖像引用我有一個ApplicationAdvice
類,通過每個頁面上引用的資料圖片:傳遞字符串到ApplicationAdvice
@ControllerAdvice
public class ApplicationAdvice {
...
@ModelAttribute("currentProfilePicture")
public String currentProfilePicture(Principal principal, Model model) {
if (principal != null) {
String currentProfilePicture = "@{/images/default-profile-picture.png}";
log.info(currentProfilePicture);
model.addAttribute("currentProfilePicture", currentProfilePicture);
return currentProfilePicture;
} else {
String currentProfilePicture = "@{/images/default-profile-picture.png}";
log.info(currentProfilePicture);
model.addAttribute("currentProfilePicture", currentProfilePicture);
return currentProfilePicture;
}
}
}
HTML:
<img class="profilePicture hvr-pulse-grow" th:src="${currentProfilePicture}" />
我不是逃避靜正確引用? @{/images/default-profile-picture.png}
URL字符串打印出來罰款...我基本上只是想傳遞一個字符串到一個靜態文件到img標籤。