java - 位于服务器中的 Thymeleaf 图像绑定
问题描述
我需要使用 thymeleaf 读取位于我的 html 中服务器位置的图像,以便在邮件中发送图像,而不是作为附件,而是作为内容。我直接在我的html中使用了这样的东西,
<img alt="imagelogo" th:src = "${imageSrc}/logo.png" width="210" style="display: block;" />
我的java代码如下,
String imgsrc = ""; // Some Path that has been set from my server property file.
final Context ctx = new Context(locale);
ctx.setVariable("imageSrc", imgsrc);
但我遇到了以下异常,
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "${imageSrc}/logo.png"
解决方案
推荐阅读
- daml - 在 DAML 中,如何在选择中获取 ContractId
- javascript - 在提交表单和使用快照检索数据后,防止在 Firebase 应用程序中重复邮件 ID 和 ph num 而无需身份验证
- python - 在 Python 中等待非阻塞用户输入时显示提示
- c - 将 Keras 模型转换为 C
- django - 如何在 Django 框架中使用 Jinja?
- unit-testing - Spock - 超时后成功通过测试
- python - 从元组列表中获取唯一元素的问题
- google-chrome - Not able to find elements in side a iframe using xpath
- haskell - 了解翻转功能
- java - JAXB 父子节点同名。子节点返回空值