I want render PDF from Thymeleaf template. I have some issue with specifying path for the image that stored in resources/static/images/writing.png
<img th:src="@{/images/writing.png}" alt=""></img>
Code above works well if I open page at a web browser but it throws exception when I try process it with the TemplateEngine
Link base "/images/writing.png" cannot be context relative (/...) unless the context used for executing the engine implements the org.thymeleaf.context.IWebContext interface (template: "TimetablePDF" - line 64, col 26)
I have an option to specify full path at src like http://localhost/images/... but I think its awful, I dont want do that.
So how can I specify it without hardcoding?
This works for me
<img th:src="@{classpath:static/images/writing.png}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With