I need to add a css file externally from a location to my .ftl file. I tried this,
<link href="css/style.css" rel="stylesheet" />
is not working. And more over, when i used internal, the content is printing in the PDF file as it is.
Is there any way to resolve this issue?
Cheers!
The Free Marker Template default classpath, for static resources, is src/main/resources/static/
, as src/main/resources/templates/
for *.ftl
files.
So from a .ftl
file in the src/main/resources/templates/
access an external .css
file, you should use link href="css/your.css"
rel="stylesheet"/>
while your.css
file is in src/main/resources/static/css/
It worked for me.
Are you sure you're linking to the CSS file correctly? Maybe absolute path can fix it
<link href="/css/style.css" rel="stylesheet" />
Depends on your file structure, of course
EDIT - note the "/" in your href attribute. signifies absolute positioning mate. or you can use "../" Again, depends on your file structure.
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