Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include CSS file in a Free Marker Template

Tags:

html

css

jsp

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!

like image 986
steeve Avatar asked Aug 07 '13 06:08

steeve


2 Answers

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.

like image 172
JSan Avatar answered Oct 13 '22 16:10

JSan


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.

like image 42
Akira Dawson Avatar answered Oct 13 '22 17:10

Akira Dawson