Reputation: 494
I have a problem with CSS path in my project. This is the file structure of a Spring Maven project.
In jsp page I wrote:
<link rel="stylesheet" href="/Treninky/css/bootstrap.css" />
But it still does not work. I can't find a solution. Could anyone help me?
Upvotes: 0
Views: 696
Reputation: 2052
Flelix good advice
Best practice to get path of any folder from the project is: (as per flelix advice structure),
<LINK REL="SHORTCUT ICON" HREF="<%=request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()%>/src/css/bootstrap.css">
Upvotes: 0
Reputation: 343
add this to your web.xml
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
and it's better to move your css to another directory like src/main/resources
or somewhere that not in WEB-INF
Upvotes: 2
Reputation: 38112
I'd suggest you to put your css
file under css
folder inside src
folder:
Treninky >
src >
css/bootstrap.css
Then you can use:
<link rel="stylesheet" href="/Treninky/src/css/bootstrap.css" />
Upvotes: 0
Reputation: 9872
Resources under WEB-INF directory are not visible outside the application. You should have your /css directory straight under your webapp directory in order for it to be visible.
Something like
src/
/main
/webapp
/Treninky
/css/*.css
And then your /css directory would be reachable
Upvotes: 2