问题
I am new to thymeleaf and jhipster, I'm currently working on an email template with thymeleaf. I need to add a logo image into the email. I tried many methods but I'm confused where to save images and how to add then into the html template of email. th:src=@{/logo.png} - I used this tag and my image are inside project-web-app\src\main\webapp\logo.png.
回答1:
The source of your image should point to an absolute URL with hostname that can be reached by mail reader.
In JHipster 3, this URL can be configured in application*.yml
in jhipster.mail.base-url
property. You can see it being used in src/main/resources/mails/activationEmail.html
for registration link.
In your case, your template should refer to your image like this: th:src="@{|${baseUrl}/logo.png|}"
.
来源:https://stackoverflow.com/questions/41867321/thymeleaf-unable-to-add-a-logo-to-the-email