'<h:outputStylesheet> doesn't render anything to HTML
I'm using JSF2 and primefaces, and cannot get the css sheet to load.
The CSS is stored @ WebContent/resources/css/style.css
xhtml:
<h:head></h:head>
<h:body>
<h:outputStylesheet name="css/styles.css" />
I've tried locating h:outputStylesheet within h:head and have also tried using the library="css" tag to no avail.
The output html as follows:
<head>
<link type="text/css" rel="stylesheet" href="/WireTapLogSearchUtility/faces/javax.faces.resource/theme.css?ln=primefaces-home" />
<link rel="stylesheet" media="screen" type="text/css" href="/WireTapLogSearchUtility/faces/javax.faces.resource/primefaces.css?ln=primefaces&v=3.2" />
<script type="text/javascript" src="/WireTapLogSearchUtility/faces/javax.faces.resource/jquery/jquery.js?ln=primefaces&v=3.2"><!--//-->
</script><script type="text/javascript" src="/WireTapLogSearchUtility/faces/javax.faces.resource/primefaces.js?ln=primefaces&v=3.2"><!--//-->
</script><script type="text/javascript" src="/WireTapLogSearchUtility/faces/javax.faces.resource/jsf.js?ln=javax.faces"><!--//--></script>
</head>
using ctrl+f on the source there is no results for style.css
Additionally I do have the mapping in web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Solution 1:[1]
The tags h:outputScript and/or h:outputStylesheet do not render anything if the resource can not be found on disk. Test the URl with:
http://localhost:8080/MyApp/javax.faces.resource/css/mycss.css
where "MyApp" is a name of your servlet and "mycss.css" name of the file contained in the folder "resources/css/". If you do not get 404 then <h:outputStylesheet library="css" name="mycss.css"></h:outputStylesheet> should work fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sergej Zr |
