Linking to a CSS file in JSF?

rich picture rich · May 2, 2011 · Viewed 10.5k times · Source

Within <h:head/> tags I have:

<h:outputStylesheet name="css/common.css" />

This is output as:

<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND" />

The stylesheet is within a folder named css under the webapp folder of my maven war. When I browse to http://localhost:8080/mywar/css/common.css I see the stylesheet.

Any ideas what I'm missing? Thanks in advance.

Answer

rich picture rich · May 2, 2011

I followed the directory structure and layout from tip 4 here: http://www.ibm.com/developerworks/java/library/j-jsf2fu1/index.html

Essentially moved the css folder to be under one called resources and then referenced it as:

<h:outputStylesheet library="css" name="common.css" />

Now it seems to work!