Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find resource css, style.css [duplicate]

Tags:

xhtml

jsf

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?

like image 833
jisteinberg Avatar asked Dec 12 '22 00:12

jisteinberg


2 Answers

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:

enter image description here

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?

like image 140
Tarik Avatar answered Dec 17 '22 19:12

Tarik


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

like image 26
Yahya Almubarak Avatar answered Dec 17 '22 20:12

Yahya Almubarak