I have a problem with my CSS file. I'm testing a stylesheet but I can't seem to be able to link it to HTML unless they're on the same folder. Here's my package structure
index.jsp is in WebContent and styles.css in WEB-INF/css/styles.css relative to index.jsp. This is how I'm trying to link the file:
<link rel="stylesheet" type="text/css" href="WEB-INF/css/styles.css">
But this does nothing. However, when I put styles.css in the same folder as index.jsp and change this line to
<link rel="stylesheet" type="text/css" href="styles.css">
it works just fine. I know my path is correct in the original case because I can ctrl+click to open the css file from the jsp file in Eclipse, so, what am I doing wrong?
The WEB-INF
folder is by definition not accessible via HTTP request; if you want to serve any content from the WEB-INF
folder, it has to be done using Servlet/JSP.
Solution: put your CSS file(s) outside the WEB-INF
folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.