I created a Java JSF application in NetBeans 8.02 with GlassFish 4.1. One of the web pages created as a facelet contains the following tags:
<h:head>
<title>Address Book: Add Entry</title>
<h:outputStylesheet name="style.css" library="css"/>
</h:head>
When I run the application I get the error:
Unable to find resource css, style.css
I look in the Web Pages/ resources /css folder in my project and style.css is present. If I add the style.css folder from another project, everything works fine.
What do I need to do so that either style.css is automatically placed in the correct folder instead of me manually having to do it --- or is there something missing in how I set up my project or wrote the xhtml tag?
Seems to me that you are not using the correct /resources folder, you should use the /resources directory in the root of your web application as mentionned by Tiny's comment (subfolder of WebContent), And not the resources folder which contain your java classes. Here is an example:
However, you are not correctly using the h:outputStylesheet
, you should better use it like this:
<h:outputStylesheet name="css/styles.css" />
A detailled answer regarding the JSF resource library was provided by BalusC: What is the JSF resource library for and how should it be used?
I had the same problem with NetBean 8.1. I solved this problem by writing
h:outputStylesheet name="resources/css/default.css"
h:outputStylesheet name="resources/css/cssLayout.css"
I did not change the location to the style files: the path to the stylesheet files in the project view of NetBean 8.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With