-1

enter image description here

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?

Mert Serimer
  • 1,217
  • 2
  • 16
  • 38

2 Answers2

4

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>
JanPl
  • 794
  • 6
  • 19
0

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.

Tim
  • 628
  • 5
  • 17