How should i reference it from xhtml? According to what i found on the net, file should be here as picture above but some said also i need some resource loc mapping servlet-config.xml
where is this file? What is my href
path?

- 1,217
- 2
- 16
- 38
-
Stop marking this as duplicate, leave this topic if you don't have something contribute to – Mert Serimer Nov 03 '16 at 08:46
-
2I recommend to take a break. – BalusC Nov 03 '16 at 08:52
-
Look at the picture please. Tell me if something is not as you say – Mert Serimer Nov 03 '16 at 08:53
-
2Your picture shows you placed resources in main/resources while Jan's answer (and the duplicate) clearly says to put them in main/webapp/resources. – BalusC Nov 03 '16 at 08:54
-
This picture is DIFFERENT than the one from yesterday btw, there a plain html link was used... Wow.... – Kukeltje Nov 03 '16 at 08:56
2 Answers
Put css/style.css into the path webapp/resources/.
webapp
|-- WEB-INF
|-- resources
| |-- css
| | `-- style.css
The proper JSF 2.x way is to reference the stylesheet by using the <h:outputStylesheet />
tag.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<h:outputStylesheet name="css/style.css" />
</h:head>
<h:body>
</h:body>
</html>

- 794
- 6
- 19
-
-
2Mert, your folder structure doesn't match this answer (nor the answer in the duplicate). – BalusC Nov 03 '16 at 08:52
It looks to me like you've set it up right.
The best thing you can do in this case is load it up in Chrome's development window. It's incredibly useful and even if you don't like Chrome, is well worth using just for that particular set of tools.
So assuming you have your xhtml page open in Chrome, press F12 to open the dev window. Then click on the console tab to see if there were any errors loading the css file. Depending on where it's being hosted or accessed from, it could be a permission or CORS issue.
If there are no errors in the console, click the sources tab and then open the resource tree until you find the css file. You can get more specific information about that particular resource and get some indication of why it isn't loading.
You could also try an absolute path; however, that is somewhat non-standard and you should be able to get it to work (as you are trying to do) using relative paths. I just mention it as a last-ditch effort if you absolutely can't get relative paths to work and need a faster workaround.

- 628
- 5
- 17